I am wanting my bot to kick users if they do something an x number of times. Like an action, slapping the bot, etc. I already have a script that will make the bot slap the user back if they slap it or me, but I want it to kick if they slap the bot(or me) three times. How would a counter like this be added?
Thanks for the reply! I get an error though... if I leave it with 3 closing braces, it complains that its missing one, but if I add one, the bot dies. He did slap a test nick back once, but nothing more after that.
I've been tinkering with this... it has a few bugs that I can't seem to work out.
I think it needs to be the other way around: as in, it will just slap unless maxactions == 3, then it will kick. Reason is that with it as is, it counts three actions in general as a kick, and so will kick after 3 actions. Not good. I've tried variations of this, but I can't get it to kick:
set slapreplies {
"around a bit with a large trout. *SMACK SMACK*"
"with a two by four upside the head. *KONK*"
"with the mighty banhammer eventually :P"
"with a slimy wet eel, or something similar :P"
"then stares back. Don't expect an apology :P"
"with the holy bible autographed by jesus himself. Repent now!"
"with Chuck Norris' fist. *BOOM*"
"right back twice as hard. 2x mode activated! Final battle, Fight!"
}
set maxslaps "3"
bind ctcp * ACTION slap:back
proc slap:back {nick uhost hand chan kw arg} {
global slapped_us botnick slapreplies owner maxslaps
if {![validchan $chan]} {return 0}
if {[string match -nocase "*slap* $botnick*" $arg] || [string match -nocase "*slap* $owner*" $arg]} {
if {[info exists slapped_us($uhost)]} {
if {[incr slapped_us($uhost)] == $maxslaps} {
putserv "KICK $chan $nick :Its not polite to slap people D\:"
unset slapped_us($uhost)
return 0
}
} else {
set slapped_us($uhost) 1
}
putserv "PRIVMSG $chan :\001ACTION slaps $nick [lindex $actReplies [rand [llength $actReplies]]]\001"
}
}
Edit: fixed problem mentioned below. Solved.
Last edited by speechles on Mon Mar 15, 2010 10:35 pm, edited 2 times in total.
Ah, okay... I had tried adding another incr line cause I figured that's what needed to happen...
I am not getting any errors with that script, but the bot is not slapping or kicking at all now.
I may just have to stick with slapping the person back.
set slapreplies {
"around a bit with a large trout. *SMACK SMACK*"
"with a two by four upside the head. *KONK*"
"with the mighty banhammer eventually :P"
"with a slimy wet eel, or something similar :P"
"then stares back. Don't expect an apology :P"
"with the holy bible autographed by jesus himself. Repent now!"
"with Chuck Norris' fist. *BOOM*"
"right back twice as hard. 2x mode activated! Final battle, Fight!"
}
set maxactions "3"
bind ctcp * ACTION slap:back
proc slap:back {nick uhost hand chan kw arg} {
global slapped_us botnick slapreplies owner maxslaps
if {![validchan $chan]} {return 0}
if {[string match -nocase "*slap* $botnick*" $arg] || [string match -nocase "*slap* $owner*" $arg]} {
if {[info exists slapped_us($uhost)]} {
if {[incr slapped_us($uhost)] == $maxslaps} {
putserv "KICK $chan $nick :Please don't slap me!"
unset slapped_us($uhost)
return 0
}
} else {
set slapped_us($uhost) 1
}
putserv "PRIVMSG $chan :\001ACTION slaps $nick [lindex $slapreplies [rand [llength $slapreplies]]]\001"
}
}
Thanks, but I should have mentioned that I have long since solved this. I have it set now so that it kicks on second offense and on the third time it bans for 15 minutes, but it allows those 3 kicks only within an hour before resetting. I am using the comment field to store number of offenses though, rather than a counter like this one. I haven't had any luck running counters like that.
it wouldn't work for you as is. I use a custom proc in it that... I'm not exactly wanting to share, as it required tremendous work to get right... and I use a modified version of an alltools proc for the timer work, etc...