Code: Select all
bind mode - "* +b" enforcebans
set enforce(max) "8"
set enforce(kmsg) "Banned :ban: by :nick:"
proc enforcebans {nick uhost hand chan mc ban} {
global enforce
if {![botisop $chan]} { return }
set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
if {[string match -nocase $ban $::botnick]} { return }
set kickmsg "$enforce(kmsg)"
regsub -all :ban: $kickmsg $ban kickmsg
regsub -all :nick: $kickmsg $nick kickmsg
set list ""
foreach user [chanlist $chan] {
if {[matchattr [nick2hand $user] f $chan]} { continue }
if {[string match -nocase $ban $user![getchanhost $user $chan]]} {
lappend list $user
}
}
if {[string match [llength $list] 0]} { return }
if {[llength $list] > $enforce(max)} {
putserv "MODE $chan -ob $nick $ban"
} else {
if {[llength $list] <= "3"} {
putserv "KICK $chan [join $list ,] :$kickmsg"
} else {
set nlist ""
foreach x $list {
lappend nlist $x
if {[llength $nlist] == "3"} {
putserv "KICK $chan [join $nlist ,] :$kickmsg"
set nlist ""
}
}
if {[llength $nlist] != ""} {
putserv "KICK $chan [join $nlist ,] :$kickmsg"
set nlist ""
}
}
}
}
putlog "Enforcebans loaded."