# exec tclsh "$0" ${1+"$@"} # arfer # DALnet #Atlantis # http://www.eggtcl.net # changuard-acycle.tcl 08.12.13.22.40 # ******************************************************************************************************************************************************************************* # # ********** OPERATION ********************************************************************************************************************************************************** # # changuard-acycle.tcl will ban fixed frequency cycle bots # three parts are required within a 120 minute period and each part must be followed by a join within 5 minutes # if the duration between successive parts is consistent then the user is presumed to be a cycle bot and banned on the next join # the script functions in all bot channels where the bot has channel operator status # ******************************************************************************************************************************************************************************* # # ********** DEPENDENCIES ******************************************************************************************************************************************************* # # eggdrop 1.6.17 or later # tcl 8.4 or later # ******************************************************************************************************************************************************************************* # # ********** CHANGELOG ********************************************************************************************************************************************************** # # 08.12.13.22.40 [214 lines] [10 KB] # beta release # ******************************************************************************************************************************************************************************* # # ********** INSTALLATION ******************************************************************************************************************************************************* # # 1 configure changuard-acycle.tcl in a suitable text editor (NOT one that automatically adds line breaks to long lines) # 2 create the subdirectory scripts/changuard if it doesn't already exist # 3 put the configured changuard-acycle.tcl into the bot's scripts/changuard subdirectory # 4 add a line to the end of the bot's .conf file 'source scripts/changuard/changuard-acycle.tcl' # 5 restart the bot (not rehash) # ******************************************************************************************************************************************************************************* # # ********** CONFIGURATION ****************************************************************************************************************************************************** # # ***** configuration is not essential as some thought has been given to the optimal default settings below ***** # # set here if you wish to exempt a bot user flag # must be a boolean value # 1, yes, on, true == exempt # 0, no, off, false == not exempt set vChanguardAcycleExemptFlag 1 # if this script is configured to exempt a bot user flag, set here the actual bot user flag to exempt # allowed values are as follows # o = global operator # m = global master # n = global owner set vChanguardAcycleFlag o # set here if you wish to exempt channel ops # must be a boolean value # 1, yes, on, true = exempt # 0, no, off, false = not exempt set vChanguardAcycleExemptOps 1 # set here the banmask to use # must be one of the following integer values # 1 = nick!*user@host # 2 = nick!*@host # 3 = *!*user@host # 4 = *!*@host # 5 = nick!*user@mask # 6 = nick!*@mask # 7 = *!*user@mask # 8 = *!*@mask # 9 = nick!*user@* # 10 = nick!*@* # 11 = *!*user@* set vChanguardAcycleMaskType 10 # ******************************************************************************************************************************************************************************* # # ********** CODE *************************************************************************************************************************************************************** # # *********************************** # # *** DO NOT EDIT BELOW THIS LINE *** # # *********************************** # # ---------- FAILSAFES -------------------------------------------- # if {![string is boolean -strict $vChanguardAcycleExemptFlag]} { die "configuration error in changuard-acycle.tcl - exempt flag setting not boolean" } if {![regexp {^[omn]{1}$} $vChanguardAcycleFlag]} { die "configuration error in changuard-acycle.tcl - user flag not a permitted value" } if {![string is boolean -strict $vChanguardAcycleExemptOps]} { die "configuration error in changuard-acycle.tcl - exempt ops setting not boolean" } # ---------- INITIALISE ------------------------------------------- # set vChanguardAcycleVersion 08.12.13.22.40 # ---------- BINDS ------------------------------------------------ # bind JOIN - * pChanguardAcycleJoinDelay bind PART - * pChanguardAcyclePartScan # ---------- PROCS ------------------------------------------------ # proc pChanguardAcycleCancelOne {target chan} { global vChanguardAcycleCache if {[info exists vChanguardAcycleCache($target,$chan)]} { unset vChanguardAcycleCache($target,$chan) } return 0 } proc pChanguardAcycleCancelTwo {target chan} { global vChanguardAcycleCache if {[info exists vChanguardAcycleCache($target,$chan)]} { unset vChanguardAcycleCache($target,$chan) } return 0 } proc pChanguardAcycleCheck {target uhost chan} { global vChanguardAcycleCache vChanguardAcycleMaskType set min1 [lindex $vChanguardAcycleCache($target,$chan) 0] set min2 [lindex $vChanguardAcycleCache($target,$chan) 1] set min3 [lindex $vChanguardAcycleCache($target,$chan) 2] if {[expr {int($min3 - $min2)}] == [expr {int($min2 - $min1)}]} { if {([onchan $target $chan]) && ([botisop $chan])} { set hostmask [pChanguardAcycleMaskhost $target $uhost $vChanguardAcycleMaskType] putquick "MODE $chan +b $hostmask" putquick "KICK $chan $target :fixed frequency cycle bot" } } foreach item [timers] { if {[string equal "pChanguardAcycleCancelTwo $target $chan" [lindex $item 1]]} { killtimer [lindex $item 2] } } unset vChanguardAcycleCache($target,$chan) return 0 } proc pChanguardAcycleJoinDelay {nick uhost hand chan} { set target [subst -nocommands -nobackslashes $nick] utimer 10 [list pChanguardAcycleJoinScan $target $uhost $hand $chan] return 0 } proc pChanguardAcycleJoinScan {target uhost hand chan} { global vChanguardAcycleCache vChanguardAcycleExemptOps if {($vChanguardAcycleExemptOps) && ([isop $target $chan])} {return 0} if {[info exists vChanguardAcycleCache($target,$chan)]} { foreach item [timers] { if {[string equal "pChanguardAcycleCancelOne $target $chan" [lindex $item 1]]} { killtimer [lindex $item 2] } } switch -- [llength $vChanguardAcycleCache($target,$chan)] { 1 {timer 120 [list pChanguardAcycleCancelTwo $target $chan]} 3 {pChanguardAcycleCheck $target $uhost $chan} } } return 0 } proc pChanguardAcycleMaskhost {nick uhost type} { scan $uhost {%[^@]@%s} user host set user [string trimleft $user ~] switch -- [regexp -- {^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $host] { 0 { switch -- [regexp -all -- {\.} $host] { 0 - 1 {set mask $host} 2 {set mask *.[join [lrange [split $host .] 1 end] .]} default {set mask *.[join [lrange [split $host .] 2 end] .]} } } 1 {set mask [join [lrange [split $host .] 0 end-1] .].*} } switch -- $type { 1 {set hostmask $nick\!*$user\@$host} 2 {set hostmask $nick\!*@$host} 3 {set hostmask *!*$user\@$host} 4 {set hostmask *!*@$host} 5 {set hostmask $nick\!*$user\@$mask} 6 {set hostmask $nick\!*@$mask} 7 {set hostmask *!*$user\@$mask} 8 {set hostmask *!*@$mask} 9 {set hostmask $nick\!*$user\@*} 10 {set hostmask $nick\!*@*} 11 {set hostmask *!*$user\@*} } return $hostmask } proc pChanguardAcyclePartScan {nick uhost hand chan msg} { global vChanguardAcycleCache vChanguardAcycleExemptFlag vChanguardAcycleFlag set target [subst -nocommands -nobackslashes $nick] if {[isbotnick $target]} {return 0} if {($vChanguardAcycleExemptFlag) && ([matchattr $hand $vChanguardAcycleFlag])} {return 0} lappend vChanguardAcycleCache($target,$chan) [expr {floor([clock seconds] / 60.00)}] timer 5 [list pChanguardAcycleCancelOne $target $chan] return 0 } # ---------- ACKNOWLEDGEMENT -------------------------------------- # putlog "<\00314changuard\003> changuard-acycle.tcl version $vChanguardAcycleVersion by arfer loaded" # eof