Code: Select all
if {($letter == "?") || ($letter == "!") || ($letter == "$") || ($letter == "_") || ($letter == "*") || ($letter == "%") || ($letter == "¿") || ($letter == "¡") || ($letter == "ñ") || ($letter == "á") || ($letter == "é") || ($letter == "í") || ($letter == "ó") || ($letter == "ú") || ($letter == "[") || ($letter == "]") || ($letter == "{") || ($letter == "}") || ($letter == "<") || ($letter == ">") || ($letter == "|") || ($letter == "ç") || ($letter == ".") || ($letter == "¨")} {incr annoy; incr total_annoy}
Code: Select all
set annoy_count(z:z) 0
set annoy_triggered(z:z) 0
##CHECK_ANNOY
proc check_annoy {nick uhost hand chan text} {
#load some global variables
global chanpro annoy_count annoy_triggered botnick annoy_ban_type
#set the annoy variables
set annoy 0
set total_annoy 0
set triggered 0
#check if annoy-check is disabled, if so - return
if {!$chanpro(annoy)} {return 0}
#check if other bot is actually typing the word <- Added to fix bugs
if {[matchattr $hand +b]} {return 0}
#check each char with a loop
foreach word [split $text] {
foreach letter [split $word ""] {
if {($letter == "?") || ($letter == "!") || ($letter == "$") || ($letter == "_") || ($letter == "*") || ($letter == "%")} {incr annoy; incr total_annoy}
}
#checks if the length of the annoy is huge enough
if {$annoy >= $chanpro(annoy_length)} {break} {set annoy 0}
}
#set some vars again
set total_string [expr [string length $text] - [regsub -all -- " " $text * *]]
set percent [expr $total_annoy.0 / $total_string * 100]
#check if the annoy was big enough
if {$annoy >= $chanpro(annoy_length)} {
set triggered 1
}
#check if the percentage was big enough, and string was long enough to count
if {$total_string >= $chanpro(annoy_minimum) && $percent >= $chanpro(annoy_percent)} {
set triggered 1
}
#check if we got a trigger
if {!$triggered} {
return 0
}
##now, proceed to the actual actions the bot will take
##create a timer for the violation, kick/ban..
#checks if the user is an op, if so check if protect_ops is enabled
if {([matchattr $hand o|o $chan] || [isop $nick $chan]) && $chanpro(protect_ops)} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_annoy)]"
return 0
}
#check if the dude has triggered before
if {![info exists annoy_count($uhost:$chan)]} {
set annoy_count($uhost:$chan) 0
}
#increase the variable thar tracks number of offences
incr annoy_count($uhost:$chan)
#check if we allready have a timer set, and kill it if so (prevent error msgs and bad timers)
if {[info exists annoy_triggered($uhost:$chan)]} {killtimer $annoy_triggered($uhost:$chan); list unset annoy_triggered($uhost:$chan)}
#set our timer, bound to a variable..
set annoy_triggered($uhost:$chan) [timer $chanpro(remember) [list unset annoy_count($uhost:$chan)]]
timer $chanpro(remember) [list unset annoy_triggered($uhost:$chan)]
#check what offencenr this was, and act from it
if {$annoy_count($uhost:$chan) == 1} {putserv "[subst $chanpro(warning_method)] :[subst $chanpro(warn_annoy)]"}
if {$annoy_count($uhost:$chan) == 2} {putserv "KICK $chan $nick :[subst $chanpro(kick_annoy)]"}
if {$annoy_count($uhost:$chan) == 3} {
set bmask [annoy:masktype $nick!$uhost $annoy_ban_type]
newchanban $chan $bmask $botnick [subst $chanpro(ban_annoy)] $chanpro(ban_time_annoy)
putserv "KICK $chan $nick :[subst $chanpro(ban_annoy)]"
set annoy_count($uhost:$chan) 2
putloglev o * "*** Kickban $nick from $chan for doing $chanpro(ban_annoy)"
}
} ;#end proc
