Administrator & All HeLpers.
This Is The tcl wich was original written by SpiKe^^ i need some changing in it nothing much just need to be change ban mask option . in this tcl bot ban ip with full host *!*@182.178.23.63 like this i like to change it into just ban host. like this is ip @pool-108-52-22-104.phlapa.fios.verizon.net ban should be *!*@*.verizon.net --- just ban the last host .
Code: Select all
## remove-damn-spam-bots.tcl v1.4 (13May2015) by SpiKe^^ ##
# Spam bots joins, kick-ban on joins:seconds #
set rdsb(flood) 3:10
# Spam bots joins kick-ban reason #
set rdsb(reasn) "10Possibel/Spammer/Flooder! If Not join1 #gEtHeLp"
# Max number of bans to stack in one mode command #
set rdsb(maxb) 6
# Length of time in minutes to ban damn spam bots #
# - set 0 to disable this script removing bans (ex. set rdsb(btime) 0) #
set rdsb(btime) 120
# After a valid damn spam bot join flood, script will continue #
# to kick-ban offenders for an additional 'x' seconds #
set rdsb(xpire) 15
# Set channel mode(s) on flood detected. #
# - set empty to disable setting channel modes (ex. set rdsb(mode) "") #
set rdsb(mode) "M-k Possible.Flooder"
# Remove these channel modes after how many seconds? #
set rdsb(mrem) 20
# END OF SETTINGS # Don't edit below unless you know what you're doing #
bind join - * rdsb_bindjoin
proc rdsb_bindjoin {nick uhost hand chan} {
global rdsb rdsc rdsq
if {[isbotnick $nick]} { return 0 }
if {[matchattr $hand f|f $chan]} { return 0 }
if {![string match "~*" $uhost]} { return 0 }
set user [string range [lindex [split $uhost @] 0] 1 9]
if {$user ne [string range $nick 0 8]} { return 0 }
set uhost [string tolower $nick!$uhost]
set chan [string tolower $chan]
set utnow [unixtime]
set target [lindex $rdsb(flood) 0]
if {[info exists rdsc($chan)]} {
set uhlist [lassign $rdsc($chan) cnt ut]
set utend [expr {$ut + [lindex $rdsb(flood) 1]}]
set expire [expr {$utend + $rdsb(xpire)}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rdsc($chan) }
} elseif {$utnow > $expire} { unset rdsc($chan) }
}
if {![info exists rdsc($chan)]} {
set rdsc($chan) [list 1 $utnow $uhost]
return 0
}
incr cnt
if {$cnt <= $target} {
if {[lsearch $uhlist $uhost] == -1} { lappend uhlist $uhost }
if {$cnt < $target} {
set rdsc($chan) [linsert $uhlist 0 $cnt $ut]
} else {
set rdsc($chan) [list $cnt $ut]
if {$rdsb(mode) ne "" && [string is digit -strict $rdsb(mrem)]} {
putquick "MODE $chan +$rdsb(mode)"
utimer $rdsb(mrem) [list putquick "MODE $chan -$rdsb(mode)"]
}
rdsb_dobans $chan $uhlist
}
return 0
}
if {![info exists rdsq($chan)]} {
utimer 2 [list rdsb_bque $chan]
set rdsq($chan) [list $uhost]
} elseif {[lsearch $rdsq($chan) $uhost] == -1} {
lappend rdsq($chan) $uhost
}
if {[llength $rdsq($chan)] >= $rdsb(maxb)} {
rdsb_dobans $chan $rdsq($chan)
set rdsq($chan) ""
} elseif {[botisop $chan]} { putquick "KICK $chan $nick :$rdsb(reasn)" }
return 0
}
proc rdsb_dobans {chan uhlist} {
global rdsb
if {![botisop $chan]} return
set banList ""
set nickList ""
foreach ele $uhlist {
scan $ele {%[^!]!%[^@]@%s} nick user host
set bmask "*!*@$host"
if {[lsearch $banList $bmask] == -1} { lappend banList $bmask }
if {[lsearch $nickList $nick] == -1} { lappend nickList $nick }
}
stack_bans $chan $rdsb(maxb) $banList
foreach nk $nickList {
if {[onchan $nk $chan]} { putquick "KICK $chan $nk :$rdsb(reasn)" }
}
if {$rdsb(btime) > 0} {
set expire [expr {[unixtime] + $rdsb(btime)}]
lappend rdsb(rmls) [list $expire $chan $banList]
}
}
proc stack_bans {chan max banlist {opt +} } {
set len [llength $banlist]
while {$len > 0} {
if {$len > $max} {
set mode [string repeat "b" $max]
set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
set banlist [lrange $banlist $max end]
incr len -$max
} else {
set mode [string repeat "b" $len]
set masks [join $banlist]
set len 0
}
putquick "MODE $chan ${opt}$mode $masks"
}
}
proc rdsb_bque {chan} {
global rdsq
if {![info exists rdsq($chan)]} { return }
if {$rdsq($chan) eq ""} { unset rdsq($chan) ; return }
rdsb_dobans $chan $rdsq($chan)
unset rdsq($chan)
}
proc rdsb_breset {} {
global rdsc rdsb
set utnow [unixtime]
set target [lindex $rdsb(flood) 0]
foreach {key val} [array get rdsc] {
lassign $val cnt ut
set utend [expr {$ut + [lindex $rdsb(flood) 1]}]
set expire [expr {$utend + $rdsb(xpire)}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rdsc($key) }
} elseif {$utnow > $expire} { unset rdsc($key) }
}
if {[info exists rdsb(rmls)]} {
while {[llength $rdsb(rmls)]} {
set next [lindex $rdsb(rmls) 0]
lassign $next expire chan banList
if {$expire > $utnow} { break }
set rdsb(rmls) [lreplace $rdsb(rmls) 0 0]
if {![info exists rmAra($chan)]} { set rmAra($chan) $banList
} else { set rmAra($chan) [concat $rmAra($chan) $banList] }
}
foreach {key val} [array get rmAra] {
set banList ""
foreach mask $val {
if {![ischanban $mask $key]} { continue }
lappend banList $mask
}
if {$banList eq ""} { continue }
if {![botisop $key]} {
set rdsb(rmls) [linsert $rdsb(rmls) 0 [list $utnow $key $banList]]
} else { stack_bans $key $rdsb(maxb) $banList - }
}
if {![llength $rdsb(rmls)]} { unset rdsb(rmls) }
}
utimer 30 [list rdsb_breset]
}
if {![info exists rdsb_running]} {
utimer 20 [list rdsb_breset]
set rdsb_running 1
}
set rdsb(flood) [split $rdsb(flood) :]
set rdsb(btime) [expr {$rdsb(btime) * 60}]
if {$rdsb(btime)==0 && [info exists rdsb(rmls)]} { unset rdsb(rmls) }
putlog "Loaded remove-damn-spam-bots.tcl v1.4 by SpiKe^^"