proc throttled {id time} {
global throttled
if {[info exists throttled($id)]} {
return 1
} {
set throttled($id) [clock sec]
utimer $time [list unset throttled($id)]
return 0
}
}
example limiting usage by same user@host on a specific channel
(the id part can be what ever you like of course)
Code:
bind pub n !test pub:test
proc pub:test {n u h c a} {
if {[throttled $u,$c 30]} {
puthelp "PRIVMSG $c :$n: denied. (wait or try a different channel)"
} else {
puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)"
}
}
I've got a question times how I can query the seconds that are still open?
if 60 sekungen are set.
wait 35 seconds.
If the user then the commands used. say to the bot may wish to wait 25 seconds.
is that possible?
Last edited by Diamond85 on Fri Dec 21, 2012 8:11 pm, edited 1 time in total.
proc throttled {id time} {
global throttled
if {[info exists throttled($id)]} {
return [expr {($throttled($id)+$time)-[clock sec]}]
} {
set throttled($id) [clock sec]
utimer $time [list unset throttled($id)]
return 0
}
}
example limiting usage by same user@host on a specific channel
(the time & id parts can be what ever you like of course)
Code:
bind pub n !test pub:test
proc pub:test {n u h c a} {
if {[set timeleft [throttled $u,$c 30]]} {
puthelp "PRIVMSG $c :$n: denied. (wait $timeleft seconds)"
} else {
puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)"
}
}