Hello.
I run a tcl script which answers users ctcp triggers.
I wonder how to make the script ignore a trigger from one specific user for a 3 mns period.
Thanks in advance.
Sibelius
Code: Select all
newignore hostmask creator comment ?lifetime?
Code: Select all
proc throttled {id seconds} {
global throttle
if {[info exists throttle($id)]&&$throttle($id)>[clock sec]} {
set id 1
} {
set throttle($id) [expr {[clock sec]+$seconds}]
set id 0
}
}
# delete expired entries every 10 minutes
bind time - ?0* throttledCleanup
proc throttledCleanup args {
global throttle
set now [clock sec]
foreach {id time} [array get throttle] {
if {$time<=$now} {unset throttle($id)}
}
}
Code: Select all
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
}
}
Code: Select all
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)"
}
}