The following script listens on a socket and sends the result into an IRC channel.
It works.
I want it to not send identical messages in a row. Therefore I'd like to store the $msg before it is send out to the channel, and check the next time, before a message is sent, if the stored text is identical to $msg.
If so, the script should interrupt and wait for the next piece of incoming data.
My question basically is: What kind of variable do i need to store the message? a global, or var? I tried to set up a simple loop all night long but it just didnt work.
Here's the code:
Code: Select all
socket -server blubb 4711
proc blubb {cid addr port} {
fconfigure $cid -buffering line -blocking 0;
fileevent $cid readable "bbb $cid"
}
proc bbb {cid} {
if {[gets $cid msg] == ""} {
putserv "PRIVMSG #grill-bill :empty"
close $cid; return
}
putserv "PRIVMSG #grill-bill :$msg"
close $cid; return
}