And you can use this when u need to set a ban on someone in a proc
Example:
Code: Select all
##########################
## Proc for the banmask ##
##########################
proc BanMsk {uhost} {
if {[string match -nocase "*@*irccloud*" $uhost]} {
return "*!*[string map {sid id uid id} [string trimleft [lindex [split $uhost @] 0] "~"]]@*"
} else { return "*!*@[lindex [split $uhost "@"] 1]" }
}
#####################################
## Proc for checking access levels ##
#####################################
proc AccessChker {nick chan} { if {[matchattr [nick2hand $nick] o|o $chan]} { return 1 }; foreach type {op halfop} { if {[is$type $nick $chan]} { return 1 } }; return 0 }
proc NOAccessChker {nick chan} { if {[matchattr [nick2hand $nick] of|of $chan]} { return 1 }; foreach type {op halfop} { if {[is$type $nick $chan]} { return 1 } }; return 0 }
#####################
## Proc for kickban #
#####################
bind pub -|- !kb Pub:Kban
proc Pub:Kban {nick uhost hand chan text} {
if {![AccessChker $nick $chan]} { return 0 }
set text [split [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]]
set target [lindex [split $text] 0]
set reason [join [lrange [split $text] 1 end]]
if {![llength $text]} { putserv "Notice $nick :Syntax is !KB \<nick\> \<reason\>" ; return 0 }
if {[NOAccessChker $target $chan]} { return 0 }
if {$reason eq ""} { set reason "Requested." }
if {[AccessChker $target $chan]} { return 0 }
set lastChar [string index $reason end]
if {$lastChar ni {\. ! ?}} { append reason "." }
if {![onchan $target $chan]} {
putserv "Notice $nick :$target is not on channel $chan"
} else {
if {![ischanban [BanMsk $chost] $chan]} { putserv "mode $chan +b [BanMsk $chost]" }
putserv "kick $chan $target :$reason"
}
}
##################
## Proc for kick #
##################
bind pub -|- !k Pub:Kicker
proc Pub:Kicker {nick uhost hand chan text} {
if {![AccessChker $nick $chan]} { return 0 }
set text [split [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]]
set target [lindex [split $text] 0]
set reason [join [lrange [split $text] 1 end]]
if {![llength $text]} { putserv "Notice $nick :Syntax is !K \<nick\> \<reason\>" ; return 0 }
if {[NOAccessChker $target $chan]} { return 0 }
if {$reason eq ""} { set reason "Requested." }
if {[AccessChker $target $chan]} { return 0 }
set lastChar [string index $reason end]
if {$lastChar ni {\. ! ?}} { append reason "." }
if {![onchan $target $chan]} {
putserv "Notice $nick :$target is not on channel $chan"
} else { putserv "kick $chan $target :$reason" }
}