when I use this proc?
Code: Select all
proc protection:ban { nick host hand chan arg } {
global protection
if {![channel get $chan protection(flag)]} {
putserv "NOTICE $nick :Error. Protection is disabled. Enable it by typing $protection(trigger)protection on in order to use ban."
return
} elseif {$arg == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $protection(trigger)ban 'nick' 'duration' 'reason'."
} elseif {
set protection(banuser) [lindex [split $arg] 0]
set protection(banhost) "*![getchanhost $protection(banuser) $chan]"
set protection(duration) [lindex [split $arg] 1]
set protection(reason) [join [lrange [split $arg] 2 end]]
if {![isnumber $protection(duration)]} {
set protection(reason) [join [lrange [split $arg] 1 end]]
set protection(duration) "60"
}
if {![onchan $protection(banuser) $chan] && ![string match "*!*" $protection(banuser)} {
set protection(banhost) "$protection(banuser)*!*@"
putquick "MODE $chan +b $protection(banhost)"
putserv "NOTICE $nick :Done. $protection(banhost) successfully added."
}
if {[string match "*!*" $protection(banuser)] && [matchattr [nick2hand $nick] n|n $chan]} {
set protection(banhost) "$protection(banuser)"
if {$protection(banhost) == "*!*@*"} {
return
} else {
putquick "mode $chan +b $protection(banhost)"
putserv "NOTICE $nick :Done. $protection(banhist) successfully added."
}
}
if {[isbot $protection(banuser)]} {
putserv "NOTICE $nick :Error. You cannot ban the bot."
return
}
if {[matchattr [nick2hand $nick] o|o $chan] && [matchattr [nick2hand $protection(banuser)] mn|mn $chan]} {
putserv "NOTICE $nick :Error. You cannot ban $protection(banuser) from $chan (higher access level)."
return
}
if {[matchattr [nick2hand $nick] m|m $chan] && [matchattr [nick2hand $protection(banuser)] n|n $chan]} {
putserv "NOTICE $nick :Error. You cannot ban $protection(banuser) from $chan (higher access level)."
return
}
if {[isdynamicip $protection(banhost)]} {
set protection(banhost) "[maskhost $protection(banhost)]"
}
set protection(id) [channel get $chan "$protection(kickid)"]
incr protection(id)
channel set $chan protection(kickid) "$protection(id)"
regsub -all -- {:reason:} $protection(kickmsg) $protection(reason) protection(kickmsg)
regsub -all -- {:id:} $protection(kickmsg) $protection(id) protection(kickmsg)
newchanban $chan $protection(banhost) $handle "$protection(kickmsg)" $protection(duration)
putquick "KICK $chan $protection(banuser) :$protection(kickmsg)"
}
}