1. React to a a public command in the form of "!command"
2. Execute something on the shell (Unix)
3. Set a timer so repeating of "!command" in short succession on the channel doesn't work for another X minutes (as a safeguard against flooding / bringing down the machine)
4. Scan the output of the shell command until a certain line shows up (execution time may be up to two minutes, output is a couple of lines)
5. Once that line has been registered, send some text to the channel
Any pointers? Any existing script that lends itself to be modified for this purpose? Anyone willing to whip something up quickly?
this will spawn the supplied UNIX command in background, displaying its output as soon as such is available, disabling running new commands until current one is completed (not tested):
set inuse 0
bind pub n !exec foo
proc foo {n u h c t} {
if !$::inuse {
set ::inuse 1; set f [open "|$t"]
fconfigure $f -blocking 0 -buffering line
fileevent $f readable "moo $f $c"
}
}
proc moo {f c} {
puthelp "privmsg $c :[gets $f]"
if [eof $f] {set ::inuse 0; close $f}
}