23/11/2012, 22:07
Just a random thought there, but shouldn't it be [isop] rather than ![isop] o_o ?
Anyway - if i understood correctly what you want is simply a custom output queue ?
Here's a somewhat different approach than CC's. I tested it quickly with a bare tcl interp, it should work on eggdrops just as well :
You can bind !stop directly to clearHelpQueue, and then just use pushHelpQueue instead of puthelp/putquick in the script.
Anyway - if i understood correctly what you want is simply a custom output queue ?
Here's a somewhat different approach than CC's. I tested it quickly with a bare tcl interp, it should work on eggdrops just as well :
Code :
set ::helpQueue {}
set ::helpQueueTimer {}
set ::helpQueueDelay 2500 ;# One message every 2500 ms
# Reset queue status
proc clearHelpQueue {args} {
set ::helpQueue {}
set ::helpQueueTimer [after cancel $::helpQueueTimer] }
proc processHelpQueue {args} {
if {![llength $::helpQueue]} { return [clearHelpQueue] }
# Pop first element from list and send it to server
putquick [lindex $::helpQueue 0]
if {[llength [set ::helpQueue [lrange $::helpQueue 1 end]]]} {
# Init timer for next iteration if there's more to send, otherwise stop
set ::helpQueueTimer [after $::helpQueueDelay ::processHelpQueue]
} else { set ::helpQueueTimer {} }
}
proc pushHelpQueue {request} {
# Push the message to the queue
lappend ::helpQueue $request
# Start it if not running
if {$::helpQueueTimer == ""} { set ::helpQueueTimer [after $::helpQueueDelay ::processHelpQueue] }
}
You can bind !stop directly to clearHelpQueue, and then just use pushHelpQueue instead of puthelp/putquick in the script.