I have tested the script pretty much as it stands, after increasing the flood time to a realistic value of 30 seconds. It works fine. Perhaps a return command at the end of the proc would be proper, as below (not convinced though that it would matter in this instance).
One other thing that could I suppose effect scripts. When I copy/paste from this site to my text editor, I get a whitespace at the end of each line. If that happens to you, get rid of them before you load the script on the bot.
Code: Select all
set vChannels "#EggTCL"
set vFlood 0
bind PUB - !nicks pNicklist
proc pNicklist {nick uhost hand channel txt} {
global vChannels vFlood
if {!$vFlood} {
switch -- [llength [split $txt]] {
0 {set tchan $channel}
1 {set tchan $txt}
}
if {[info exists tchan]} {
if {[regexp {^#} $tchan]} {
if {[validchan $tchan]} {
if {[botonchan $tchan]} {
if {[lsearch -exact [string tolower $vChannels] [string tolower $tchan]] != -1} {
putserv "PRIVMSG $channel :[join [chanlist $tchan] ", "]"
}
} else {putserv "PRIVMSG $channel :-error- bot is not currently monitoring $tchan"}
} else {putserv "PRIVMSG $channel :-error- bot does not have a channel record for $tchan"}
} else {putserv "PRIVMSG $channel :-error- $tchan is not in the format of a valid channel name"}
} else {putserv "PRIVMSG $channel :-error- correct syntax is !nicks ?#channel?"}
set vFlood 1
utimer 30 [list set vFlood 0]
} else {putserv "PRIVMSG $channel :-flood- please try again later"}
return 0
}
This is the output at in the channel #EggTCL on DALnet :-
[20:45] <@arfer> !nicks
[20:45] <@Baal> Baal, Colossus, McKay, arfer
[20:45] <@arfer> !nicks
[20:45] <@Baal> -flood- please try again later
[20:45] <@arfer> !nicks
[20:45] <@Baal> -flood- please try again later
[20:45] <@arfer> !nicks
[20:45] <@Baal> -flood- please try again later
[20:46] <@arfer> !nicks
[20:46] <@Baal> Baal, Colossus, McKay, arfer
Following the first successful use of the command !nicks, subsequent use within the 30 seconds wait time results in the -flood- message. after 30 seconds the command responds again as expected.
The command has to get from your IRC client to the server and then from the server to your bot which then executes the code, responds to the server which responds to your IRC client. Whilst the Tcl code on your bot probably takes milliseconds to execute per cycle, the to'ing and fro'ing possibly takes up most if not all of the 5 seconds. Hence the next command works even though it appears to you to be within the 5 seconds flood time.
Anyway, I can now confirm that there is nothing wrong with the code (in my opinion). I don't intend modifying it further.