mIRC Home    About    Download    Register    News    Help

Print Thread
flooding problem in script #240800 28/02/13 02:03 PM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
im having a problem with reading text from a file or getting it to the channel. when i wrote the info to a file some things have to be removed. all working fine. but when i want to get it to the channel it keeps repeating the output. and then mirc quits because of flooding.

i dont know why, if anyone could tell me smile

on *:sockread:lvd: {
/var %lvd
/sockread %lvd
write test.txt %lvd
set %check1 $read(test.txt,2)
set %check2 $remove(%check1,blablablab)
printlvd %check2
}

alias printlvd {
msg %r.chan $1
}

Last edited by mehenky; 28/02/13 02:04 PM.
Re: flooding problem in script [Re: mehenky] #240801 28/02/13 02:48 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You need to slow down the output, you can not send to many commands to the server, if you change msg to echo it will work?

Maybe a timer is the best way?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: flooding problem in script [Re: mehenky] #240802 28/02/13 03:37 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
It's repeating because you're always reading line 2

Re: flooding problem in script [Re: Loki12583] #240805 28/02/13 05:21 PM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
It only has to read line 2. But when i give the command once, it floods till it quits.

Re: flooding problem in script [Re: mehenky] #240808 28/02/13 07:04 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
The code you've shown here would not cause that behavior. Are you repeatedly opening the socket?

And what do you mean by 'quits'?

Re: flooding problem in script [Re: mehenky] #240812 28/02/13 08:26 PM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
the code i use looks similar to this one:

on *:text:!getinfo:#: {
sockclose lvd
set %r.chan $chan
sockopen lvd www.host.com 80
}

on *:sockopen:lvd: {
sockwrite -nt $sockname GET /headlines.php HTTP/1.1
sockwrite -nt $sockname Host: www.host.com
sockwrite -nt $sockname $crlf
}

on *:sockread:lvd: {
/var %lvd
/sockread %lvd
write test.txt %lvd
set %check1 $read(test.txt,2)
set %check2 $remove(%check1,blablablab)
printlvd %check2
}

alias printlvd {
msg %r.chan $1
}

and what i ment with quits is: that my bot keeps sending the output of the script to the channel. it starts flooding the channel with the output. until the bot gets kicked because of flooding.

the sockets are working fine imo. it saves the content to a .txt file. it also get the right line in from the .txt file. removes the things i want. and send it to the channel. it only keeps repeating it to the channel.

Re: flooding problem in script [Re: mehenky] #240813 28/02/13 08:52 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
When you said 'give the command once', I took this as meaning you had a direct socket open somewhere and were receiving simple messages. You're reading a webpage, which is probably composed of hundreds or thousands of lines (or if it's blank or very small even the header can be 10s of lines.) - and your sockread event is hit for every one of them. Message your channel on sockclose.

Last edited by Loki12583; 28/02/13 08:54 PM.
Re: flooding problem in script [Re: Loki12583] #240814 28/02/13 09:39 PM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
the socket is working good. used same setup in prevous commands.

first i tought it was the socket but even when i pick another file with only 3 lines it does the same.

it just makes no sense to me. also because other commands with sockets working fine.

Last edited by mehenky; 28/02/13 09:40 PM.
Re: flooding problem in script [Re: mehenky] #240815 01/03/13 12:13 AM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
The socket event is being triggered for every line in the response. Every time that happens your script writes the new line to the file, but messages the same line (2) to the channel. This shouldn't be done in the sockread. Do it in the sockclose.

Since you're making an HTTP request, you should be getting an HTTP response - so it looks like you're messaging one of the header lines.

If you're unwilling to take my suggestion, to provide more information like the content you're receiving, the host you're connecting to, or any debugging information you've done yourself, then I won't be able to help you.

Re: flooding problem in script [Re: Loki12583] #240827 01/03/13 09:46 AM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
Gonna try it in socket close. Else i will provide the extra info.

Re: flooding problem in script [Re: Loki12583] #240830 01/03/13 02:58 PM
Joined: Dec 2012
Posts: 9
M
mehenky Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2012
Posts: 9
it was the sockclose.

now its working fine smile

thanks for the help loki, much appreciated!