I saw a really nice script in an IRC channel today. It just reacts to the widely known"abc slaps xyz around a bit with a large trout" by saying "/me takes the trout out of abcs hand and puts it back in the sea. Trouts saved: x".
I instantly fell in love with this script and decided that this would be a great addition to my eggdrop as it is already running the fishdrop script. The user who had this script told me that he only had it for mIRC. So I started to search the web, but all I found was the mIRC script. And to complete my misery I have to admit that I don't really know how to write a TCL script for an eggdrop.
So my question would be: Is there any coder out here who thinks this is a great idea and could write this script for me? I would really appreciate it.
The counter should be global (for all chans the bot is on) and should be saved to a file on a regular basis so that the counter doesn't get resetted when the bot restarts.
set troutfile [pwd]/trouts.save
bind ctcp - ACTION save:the:trouts
proc save:the:trouts {nick host hand dest key arg} {
if {![info exists ::trouts]} { set ::trouts 0 }
if {[string match -nocase "*slaps * around a bit with a large trout" $arg]} {
putserv "PRIVMSG $dest :\001ACTION takes the trout out of ${nick}s hand and puts it back in the sea. Trouts saved: [incr ::trouts]"
}
}
bind evnt - logfile save:trouts:file
bind evnt - prerestart save:trouts:file
proc save:trouts:file {args} {
puts [set fid [open $::troutfile w]] $::trouts
close $fid
}
bind evnt - connect-server load:trouts:file
proc load:trouts:file {args} {
set ::trouts [read [set fid [open $::troutfile r]]]
close $fid
}
set s "takes the trout out of %s's hand and puts it back in the sea. Trouts saved: %d"
if ![catch {set f [open trouts]}] {
set trouts [gets $f]; close $f
} {set trouts 0}
bind time - "%0 % % % %" save
proc save {m h d mo y} {
set f [open trouts w]; puts $f $::trouts; close $f
}
bind ctcp - ACTION slap
proc slap {n u h d k t} {
if [string equal -nocase $d $::botnick] return
if [string match -nocase *slaps* $t] {
puthelp "privmsg $d :\001ACTION[format $::s $n [incr ::trouts]]\001"
}
}