Code: Select all
namespace eval hashCheck {
setudef flag hashCheck
bind pubm - * [namespace current]::hashCheck
set setup [dict create limit 3 time 10]
proc hashCheck {nick uhost hand chan text} {
if {![channel get $chan hashCheck]} return
variable setup
variable md5hashes
set hash [md5 [split $text]]
if {[info exists md5hashes]} {
if {[lsearch [dict keys [dict get $md5hashes $chan] $hash] != -1} {
set hosts [dict get $md5hashes $chan $hash]
if {[llength $hosts] > [dict get $setup limit]} {
hashPunish $chan $hosts
dict unset md5hashes $chan $hash
} else {
dict set md5hashes $chan $hash [list [dict get $md5hashes $chan $hash] $uhost]
utimer [dict get $setup time] [list [namespace current]::hashPurge $chan $hash $uhost]
}
}
} else {
dict set md5hashes $chan $hash $uhost
}
}
proc hashPurge {chan hash uhost} {
variable md5hashes
set hosts [dict get $md5hashes $chan $hash]
set pos [lsearch -nocase $hosts $uhost]
if {$pos!=-1} {
set hosts [lreplace $hosts $pos $pos]
dict set md5hashes $chan $hash $hosts
}
foreach key [dict keys [dict get $md5hashes $chan]] {
if {![llength [dict get $md5hashes $chan $key]]} {
dict unset md5hashes $chan $key
}
}
}
}
Code: Select all
if {[lsearch [dict keys [dict get $md5hashes $chan]] $hash != -1} {
Code: Select all
if {[lsearch [dict keys [dict get $md5hashes $clan]] $hash] != -1} {
Code: Select all
# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>
# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 5:60
# Repeat flood kick-ban reason #
set rp_breason "repeat flood"
# Length of time in minutes to ban Repeat flooders #
set rp_btime 60
# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds #
set rp_blinger 10
# END OF SETTINGS # Don't edit below unless you know what you're doing #
bind pubm - * rp_pubmsg
set rp_bflood [split $rp_bflood :]
proc rp_pubmsg {nick uhost hand chan text} {
global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
set uhost [string tolower $nick!$uhost]
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set text [string tolower $text]
if {[isbotnick $nick]} { return 0 }
if {[matchattr $hand f|f $chan]} { return 0 }
set utnow [unixtime]
set target [lindex $rp_bflood 0]
if {[info exists rp_bcount($chan:$text)]} {
set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($chan:$text) }
} elseif {$utnow > $expire} { unset rp_bcount($chan:$text) }
}
if {![info exists rp_bcount($chan:$text)]} {
set rp_bcount($chan:$text) [list 1 $utnow $uhost]
return 0
}
if {$utnow <= $utend} {
incr cnt
if {[lsearch $uhlist $uhost] == "-1"} { lappend uhlist $uhost }
set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
if {$cnt < $target} { return 0 }
if {$cnt == $target} { rp_dobans $chan $uhlist
} else { rp_dobans $chan [list $uhost] }
} elseif {$cnt >= $target} { rp_dobans $chan [list $uhost] }
return 0
}
proc rp_dobans {chan uhlist} {
global rp_breason rp_btime
set hslist ""
foreach uhost $uhlist {
foreach {nk un hs} [split $uhost !@] { break }
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
if {[lsearch $hslist $hs] == "-1"} {
newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
lappend hslist $hs
}
}
}
proc rp_breset {} {
global rp_bcount rp_bflood rp_blinger
set utnow [unixtime]
set target [lindex $rp_bflood 0]
foreach {key val} [array get rp_bcount] {
lassign $val cnt ut
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($key) }
} elseif {$utnow > $expire} { unset rp_bcount($key) }
}
utimer 30 [list rp_breset]
}
if {![info exists rp_running]} {
utimer 30 [list rp_breset]
set rp_running 1
}
putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^"
Code: Select all
# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>
# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 2:10
# Repeat flood kick-ban reason #
set rp_breason "repeat flood"
# Length of time in minutes to ban Repeat flooders #
set rp_btime 1
# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds #
set rp_blinger 10
# END OF SETTINGS # Don't edit below unless you know what you're doing #
bind pubm - * rp_pubmsg
set rp_bflood [split $rp_bflood :]
proc rp_pubmsg {nick uhost hand chan text} {
global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
set uhost [string tolower $nick!$uhost]
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set text [string tolower $text]
if {[isbotnick $nick]} { return 0 }
if {[matchattr $hand f|f $chan]} { return 0 }
set utnow [unixtime]
set target [lindex $rp_bflood 0]
if {[info exists rp_bcount($chan:$text)]} {
set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($chan:$text) }
} elseif {$utnow > $expire} { unset rp_bcount($chan:$text) }
}
if {![info exists rp_bcount($chan:$text)]} {
set rp_bcount($chan:$text) [list 1 $utnow $uhost]
return 0
}
if {$utnow <= $utend} {
incr cnt
if {[lsearch $uhlist $uhost] == "-1"} { lappend uhlist $uhost }
set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
if {$cnt < $target} { return 0 }
if {$cnt == $target} { rp_dobans $chan $uhlist
} else { rp_dobans $chan [list $uhost] }
} elseif {$cnt >= $target} { rp_dobans $chan [list $uhost] }
return 0
}
proc rp_dobans {chan uhlist} {
global rp_breason rp_btime
set hslist ""
foreach uhost $uhlist {
foreach {nk un hs} [split $uhost !@] { break }
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
if {[lsearch $hslist $hs] == "-1"} {
putquick "MODE $chan +b *!*@$hs"
# newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
lappend hslist $hs
}
}
}
proc rp_breset {} {
global rp_bcount rp_bflood rp_blinger
set utnow [unixtime]
set target [lindex $rp_bflood 0]
foreach {key val} [array get rp_bcount] {
lassign $val cnt ut
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($key) }
} elseif {$utnow > $expire} { unset rp_bcount($key) }
}
utimer 30 [list rp_breset]
}
if {![info exists rp_running]} {
utimer 30 [list rp_breset]
set rp_running 1
}
putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^"
Code: Select all
# if the bot isn't OP then no point into continuing
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
Code: Select all
proc rp_dobans {chan uhlist} {
# if the bot isn't OP there's no point to continue
if {![botisop $chan]} return
set blist ""
set klist ""
# loop through uhosts
foreach uhost $uhlist {
# filter out any duplicates
if {[lsearch $blist $uhost] != -1} continue
# set the ban mask as you want
scan $uhost {%[^@]@%s} user host
# save the list with masks to ban
lappend blist "*!*@$host"
# save the list with masks to get nicks from later on cos we will destroy the $blist
lappend klist $uhost
}
# push 6 ban masks (or change to match how many bans per line the server you are on allows) at a time until the list is empty
while {[llength $blist] != 0} {
puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]"
set blist [lrange $blist 6 end]
}
# from the given uhosts we ban make a list of nicks to kick and again filter out duplicates
set nlist ""
set userlist [lreplace [chanlist $chan] 0 0]
foreach u [split $userlist] {
set uhost [getchanhost $user $chan]
scan $uhost {%[^@]@%s} user host
if {[lsearch $klist $uhost] != -1} continue
lappend nlist $u
}
# use putkick to do 6 kicks per a single line sent to server
while {[llength $nlist] != 0} {
putkick $chan [join [lrange $nlist 0 6] ","] "repeat flood"
set nlist [lrange $nlist 6 end]
}
}