Code: Select all
# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6
# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3
##############
bind pub -|- !k pub:kick
proc pub:kick {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx k }
bind pub -|- !b pub:ban
proc pub:ban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx b }
bind pub -|- !m pub:muteban
proc pub:muteban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx m }
####
bind pub -|- !ub pub:unban
proc pub:unban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx ub }
bind pub -|- !um pub:unmute
proc pub:unmute {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx um }
####
bind pub -|- !kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
global pkb storehosts
if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
return 0
}
if {[string match u* $do]} {
set plus "-"
set nickls [split [string trim $tx]]
} else {
set plus "+"
set reason [join [lrange [split $tx "."] 1 end] "."]
if {$reason eq ""} { set reason "Please change your behaviour thank you." }
set nickls [split [string trim [lindex [split $tx "."] 0]]]
}
foreach nick $nickls {
if {[string match u* $do] && [string match *!*@* $nick]} {
set bmask $nick
if {[string match um $do] && ![string match ~q:* $bmask]} {
set bmask ~q:$bmask
}
if {[ischanban $bmask $ch]} { lappend bmasks $bmask
} else { putserv "NOTICE $nk :$bmask is not a current ban on $ch" }
continue
}
set aname [string tolower "$nick@$ch"]
if {[onchan $nick $ch]} {
if {![string match u* $do]} {
if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
if {[matchattr [nick2hand $nick] o|o $ch]} { continue }
}
if {[string match {*[bm]} $do]} {
set chost [getchanhost $nick $ch]
set bmask [maskhost "$nick!$chost" 2]
if {[string match *m $do]} { set bmask ~q:$bmask }
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
lappend dvnicks $nick
}
}
if {[string match k* $do]} { lappend knicks $nick }
} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
if {![string match u* $do]} {
if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
}
set chost [lindex $storehosts($aname) 0]
set bmask [maskhost "$nick!$chost" 2]
if {[string match *m $do]} { set bmask ~q:$bmask }
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
} else { putserv "NOTICE $nk :$nick is not on channel $ch" }
}
if {[info exists dvnicks]} {
while {[set len [llength $dvnicks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "v" $pkb(maxban)]
set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
set dvnicks [lrange $dvnicks $pkb(maxban) end]
} else {
set mode [string repeat "v" $len]
set nicks [join $dvnicks]
set dvnicks ""
}
putquick "MODE $ch -$mode $nicks"
}
}
if {[info exists bmasks]} {
while {[set len [llength $bmasks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "b" $pkb(maxban)]
set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
set bmasks [lrange $bmasks $pkb(maxban) end]
} else {
set mode [string repeat "b" $len]
set masks [join $bmasks]
set bmasks ""
}
putquick "MODE $ch $plus$mode $masks"
}
}
if {[info exists knicks]} {
while {[set len [llength $knicks]] > 0} {
if {$len > $pkb(maxkick)} {
set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
set knicks [lrange $knicks $pkb(maxkick) end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putserv "KICK $ch $nicks :$reason"
}
}
}
####
bind part - * store:hosts
bind sign - * store:hosts
proc store:hosts {nk uh hn ch msg} {
set aname [string tolower $nk@$ch]
set ::storehosts($aname) [list $uh [expr {[unixtime]+300}] $hn]
}
bind time - * expire:hosts
proc expire:hosts {mn hr da mo yr} {
global storehosts
set ut [unixtime]
foreach {aname avalue} [array get storehosts] {
if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
}
}
Code: Select all
# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6
# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3
# set default ban/mute times (in minutes) #
# 0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime) 5
set pkb(m_mutetime) 60
# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype) 1
set pkb(mute_masktype) 1
set pkb(mute_maskpre) "~q:"
##############
bind pub -|- !k pub:kick
bind pub -|- .k pub:kick
proc pub:kick {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx k }
bind pub -|- !b pub:ban
bind pub -|- .b pub:ban
proc pub:ban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx b }
bind pub -|- !m pub:muteban
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx m }
bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx ub }
bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx um }
bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
global pkb storehosts
if {$uh ne "Timer"} {
if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
return 0
}
}
if {[string match u* $do]} {
set plus "-"
set nickls [split [string trim $tx]]
} else {
set plus "+"
set reason [join [lrange [split $tx "."] 1 end] "."]
if {$reason eq ""} { set reason "Please change your behaviour thank you." }
set nickls [split [string trim [lindex [split $tx "."] 0]]]
}
set seconds 0
if {[string is digit [lindex $nickls end]]} {
if {[string match {[bm]} $do] || ($do eq "kb")} {
set seconds [expr {[lindex $nickls end] * 60}]
}
set nickls [lrange $nickls 0 end-1]
} elseif {$do eq "m"} { set seconds [expr {$pkb(m_mutetime) * 60}]
} elseif {$do eq "b"} { set seconds [expr {$pkb(b_bantime) * 60}]
} elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}] }
set masktype $pkb(ban_masktype)
if {[string match *m $do]} { set masktype $pkb(mute_masktype) }
foreach nick $nickls {
if {$nick eq ""} { continue }
if {[string match u* $do] && [string match *!*@* $nick]} {
set bmask $nick
if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
set bmask $pkb(mute_maskpre)$bmask
}
if {[ischanban $bmask $ch]} { lappend bmasks $bmask
} elseif {$uh ne "Timer"} {
putserv "NOTICE $nk :$bmask is not a current ban on $ch"
}
continue
}
set aname [string tolower "$nick@$ch"]
if {[onchan $nick $ch]} {
if {![string match u* $do]} {
if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
if {[matchattr [nick2hand $nick] o|o $ch]} { continue }
}
if {[string match {*[bm]} $do]} {
set chost [getchanhost $nick $ch]
set bmask [maskhost "$nick!$chost" $masktype]
if {[string match *m $do]} { set bmask $pkb(mute_maskpre)$bmask }
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
lappend dvnicks $nick
}
}
if {[string match k* $do]} { lappend knicks $nick }
} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
if {![string match u* $do]} {
if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
}
set chost [lindex $storehosts($aname) 0]
set bmask [maskhost "$nick!$chost" $masktype]
if {[string match *m $do]} { set bmask $pkb(mute_maskpre)$bmask }
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
} else { putserv "NOTICE $nk :$nick is not on channel $ch" }
}
if {[info exists dvnicks]} {
while {[set len [llength $dvnicks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "v" $pkb(maxban)]
set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
set dvnicks [lrange $dvnicks $pkb(maxban) end]
} else {
set mode [string repeat "v" $len]
set nicks [join $dvnicks]
set dvnicks ""
}
putquick "MODE $ch -$mode $nicks"
}
}
if {[info exists bmasks]} {
if {$seconds > 0} {
utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
}
while {[set len [llength $bmasks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "b" $pkb(maxban)]
set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
set bmasks [lrange $bmasks $pkb(maxban) end]
} else {
set mode [string repeat "b" $len]
set masks [join $bmasks]
set bmasks ""
}
putquick "MODE $ch $plus$mode $masks"
}
}
if {[info exists knicks]} {
while {[set len [llength $knicks]] > 0} {
if {$len > $pkb(maxkick)} {
set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
set knicks [lrange $knicks $pkb(maxkick) end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putserv "KICK $ch $nicks :$reason"
}
}
}
####
bind part - * store:hosts
bind sign - * store:hosts
proc store:hosts {nk uh hn ch msg} {
set aname [string tolower $nk@$ch]
set ::storehosts($aname) [list $uh [expr {[unixtime]+600}] $hn]
}
bind time - * expire:hosts
proc expire:hosts {mn hr da mo yr} {
global storehosts
set ut [unixtime]
foreach {aname avalue} [array get storehosts] {
if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
}
}
Code: Select all
* Joins: John (uid479754@Test-DA54ABD8.irccloud.com)
[20:45:31] <@Nick> .b Cathe Mary John 1
[20:45:32] * BOT sets mode: +bbb *!*@48D59C09.BFD0590A.37B03A79.IP *!*@96C6E1DE.ABD124CC.73152542.IP *!*@Test-DA54ABD8.irccloud.com
to set ban this way for ircloud iden
+bbb *!*@48D59C09.BFD0590A.37B03A79.IP *!*@96C6E1DE.ABD124CC.73152542.IP *!uid479754@*
Code: Select all
if {[set chost [getchanhost $user $chan]] ne ""} {
switch -glob -- $chost {
{*.irccloud.com} - {*.mibbit.com} - {*.kiwiirc.com} - {*.8C39393E.IP} {
set mask *![lindex [split $chost @] 0]@*
}
{default} {
set mask [maskhost "$user!$chost" 2]
}
Code: Select all
# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6
# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3
# set default ban/mute times (in minutes) #
# 0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime) 5
set pkb(m_mutetime) 60
# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype) 2
set pkb(mute_masktype) 4
set pkb(mute_maskpre) "~q:"
# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"
##############
bind pub -|- !k pub:kick
bind pub -|- .k pub:kick
proc pub:kick {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx k }
bind pub -|- !b pub:ban
bind pub -|- .b pub:ban
proc pub:ban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx b }
bind pub -|- !m pub:muteban
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx m }
bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx ub }
bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx um }
bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
global pkb storehosts
if {$uh ne "Timer"} {
if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
return 0
}
}
if {[string match u* $do]} {
set plus "-"
set nickls [split [string trim $tx]]
} else {
set plus "+"
set reason [join [lrange [split $tx "."] 1 end] "."]
if {$reason eq ""} { set reason "Please change your behaviour thank you." }
set nickls [split [string trim [lindex [split $tx "."] 0]]]
}
set seconds 0
if {[string is digit [lindex $nickls end]]} {
if {[string match {[bm]} $do] || ($do eq "kb")} {
set seconds [expr {[lindex $nickls end] * 60}]
}
set nickls [lrange $nickls 0 end-1]
} elseif {$do eq "m"} { set seconds [expr {$pkb(m_mutetime) * 60}]
} elseif {$do eq "b"} { set seconds [expr {$pkb(b_bantime) * 60}]
} elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}] }
set masktype $pkb(ban_masktype)
if {[string match *m $do]} { set masktype $pkb(mute_masktype) }
foreach nick $nickls {
if {$nick eq ""} { continue }
if {[string match u* $do] && [string match *!*@* $nick]} {
set bmask $nick
if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
set bmask $pkb(mute_maskpre)$bmask
}
if {[ischanban $bmask $ch]} { lappend bmasks $bmask
} elseif {$uh ne "Timer"} {
putserv "NOTICE $nk :$bmask is not a current ban on $ch"
}
continue
}
set aname [string tolower "$nick@$ch"]
if {[onchan $nick $ch]} {
set hand [nick2hand $nick]
if {![string match u* $do]} {
if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
if {[matchattr $hand o|o $ch]} { continue }
}
set chost [getchanhost $nick $ch]
if {[string match {*[bm]} $do]} {
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
lappend dvnicks $nick
}
}
if {[string match k* $do]} { lappend knicks $nick
store:hosts $nick $chost $hand $ch pkb.tcl
}
} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
if {![string match u* $do]} {
if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
}
set chost [lindex $storehosts($aname) 0]
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
} else { putserv "NOTICE $nk :$nick is not on channel $ch" }
}
if {[info exists dvnicks]} {
while {[set len [llength $dvnicks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "v" $pkb(maxban)]
set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
set dvnicks [lrange $dvnicks $pkb(maxban) end]
} else {
set mode [string repeat "v" $len]
set nicks [join $dvnicks]
set dvnicks ""
}
putquick "MODE $ch -$mode $nicks"
}
}
if {[info exists bmasks]} {
if {$seconds > 0} {
utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
}
while {[set len [llength $bmasks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "b" $pkb(maxban)]
set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
set bmasks [lrange $bmasks $pkb(maxban) end]
} else {
set mode [string repeat "b" $len]
set masks [join $bmasks]
set bmasks ""
}
putquick "MODE $ch $plus$mode $masks"
}
}
if {[info exists knicks]} {
while {[set len [llength $knicks]] > 0} {
if {$len > $pkb(maxkick)} {
set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
set knicks [lrange $knicks $pkb(maxkick) end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putserv "KICK $ch $nicks :$reason"
}
}
}
#### protected hosts code
set pkb(phosts) [split [string trim $pkb(phosts)]]
proc mask:host {nick chost masktype do} {
set bmask [maskhost "$nick!$chost" $masktype]
foreach phost $::pkb(phosts) {
if {[string match -nocase $phost $chost]} {
set bmask "*![lindex [split $chost @] 0]@*"
break
}
}
if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
return $bmask
}
#### stored nicks & uhosts code
bind part - * store:hosts
bind sign - * store:hosts
proc store:hosts {nk uh hn ch msg} {
set aname [string tolower $nk@$ch]
set ::storehosts($aname) [list $uh [expr {[unixtime]+900}] $hn]
}
bind time - * expire:hosts
proc expire:hosts {mn hr da mo yr} {
global storehosts
set ut [unixtime]
foreach {aname avalue} [array get storehosts] {
if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
}
}
Code: Select all
set pkb(chtarget) "#Test2"
set pkb(chadmin) "#Test3"
# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6
# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3
# set default ban/mute times (in minutes) #
# 0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime) 5
set pkb(m_mutetime) 60
# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype) 2
set pkb(mute_masktype) 4
set pkb(mute_maskpre) "~q:"
# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"
##############
bind pub -|- !k pub:kick
bind pub -|- .k pub:kick
proc pub:kick {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx k }
bind pub -|- !b pub:ban
bind pub -|- .b pub:ban
proc pub:ban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx b }
bind pub -|- !m pub:muteban
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx m }
bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx ub }
bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx um }
bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
global pkb storehosts
set ch [string tolower $ch]
if {$ch eq $pkb(chtarget) || $ch eq $pkb(chadmin) } {
if {![onchan $nk $pkb(chadmin)]} { return }
}
foreach user $tx {
if {![onchan $user $pkb(chtarget)]} {
putserv "NOTICE $nk $user is not on channel $pkb(chtarget)"
} elseif {[isop $user $pkb(chtarget)]} {
putserv "notice $nk :$user is op in $pkb(chtarget) "
} else {
if {[onchan $user $pkb(chadmin)]} {
putserv "NOTICE $nk $user is on channel $pkb(chadmin) dont ban him/her"
}
}
}
if {$uh ne "Timer"} {
if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
return 0
}
}
if {[string match u* $do]} {
set plus "-"
set nickls [split [string trim $tx]]
} else {
set plus "+"
set reason [join [lrange [split $tx "."] 1 end] "."]
if {$reason eq ""} { set reason "Please change your behaviour thank you." }
set nickls [split [string trim [lindex [split $tx "."] 0]]]
}
set seconds 0
if {[string is digit [lindex $nickls end]]} {
if {[string match {[bm]} $do] || ($do eq "kb")} {
set seconds [expr {[lindex $nickls end] * 60}]
}
set nickls [lrange $nickls 0 end-1]
} elseif {$do eq "m"} { set seconds [expr {$pkb(m_mutetime) * 60}]
} elseif {$do eq "b"} { set seconds [expr {$pkb(b_bantime) * 60}]
} elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}] }
set masktype $pkb(ban_masktype)
if {[string match *m $do]} { set masktype $pkb(mute_masktype) }
foreach nick $nickls {
if {$nick eq ""} { continue }
if {[string match u* $do] && [string match *!*@* $nick]} {
set bmask $nick
if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
set bmask $pkb(mute_maskpre)$bmask
}
if {[ischanban $bmask $ch]} { lappend bmasks $bmask
} elseif {$uh ne "Timer"} {
putserv "NOTICE $nk :$bmask is not a current ban on $ch"
}
continue
}
set aname [string tolower "$nick@$ch"]
if {[onchan $nick $ch]} {
set hand [nick2hand $nick]
if {![string match u* $do]} {
if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
if {[matchattr $hand o|o $ch]} { continue }
}
set chost [getchanhost $nick $ch]
if {[string match {*[bm]} $do]} {
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
lappend dvnicks $nick
}
}
if {[string match k* $do]} { lappend knicks $nick
store:hosts $nick $chost $hand $ch pkb.tcl
}
} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
if {![string match u* $do]} {
if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
}
set chost [lindex $storehosts($aname) 0]
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
} else { putserv "NOTICE $nk :$nick is not on channel $ch" }
}
if {[info exists dvnicks]} {
while {[set len [llength $dvnicks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "v" $pkb(maxban)]
set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
set dvnicks [lrange $dvnicks $pkb(maxban) end]
} else {
set mode [string repeat "v" $len]
set nicks [join $dvnicks]
set dvnicks ""
}
putquick "MODE $ch -$mode $nicks"
}
}
if {[info exists bmasks]} {
if {$seconds > 0} {
utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
}
while {[set len [llength $bmasks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "b" $pkb(maxban)]
set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
set bmasks [lrange $bmasks $pkb(maxban) end]
} else {
set mode [string repeat "b" $len]
set masks [join $bmasks]
set bmasks ""
}
putquick "MODE $ch $plus$mode $masks"
}
}
if {[info exists knicks]} {
while {[set len [llength $knicks]] > 0} {
if {$len > $pkb(maxkick)} {
set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
set knicks [lrange $knicks $pkb(maxkick) end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putserv "KICK $ch $nicks :$reason"
}
}
}
#### protected hosts code
set pkb(phosts) [split [string trim $pkb(phosts)]]
proc mask:host {nick chost masktype do} {
set bmask [maskhost "$nick!$chost" $masktype]
foreach phost $::pkb(phosts) {
if {[string match -nocase $phost $chost]} {
set bmask "*![lindex [split $chost @] 0]@*"
break
}
}
if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
return $bmask
}
#### stored nicks & uhosts code
bind part - * store:hosts
bind sign - * store:hosts
proc store:hosts {nk uh hn ch msg} {
set aname [string tolower $nk@$ch]
set ::storehosts($aname) [list $uh [expr {[unixtime]+900}] $hn]
}
bind time - * expire:hosts
proc expire:hosts {mn hr da mo yr} {
global storehosts
set ut [unixtime]
foreach {aname avalue} [array get storehosts] {
if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
}
}
Code: Select all
# pkb.tcl version 1.3 by SpiKe^^ (5July2021)
# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6
# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3
# set default ban/mute times (in minutes) #
# 0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime) 5
set pkb(m_mutetime) 60
# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype) 2
set pkb(mute_masktype) 4
set pkb(mute_maskpre) "~q:"
# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"
##############
bind pub -|- !k pub:kick
bind pub -|- .k pub:kick
proc pub:kick {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx k }
bind pub -|- !b pub:ban
bind pub -|- .b pub:ban
proc pub:ban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx b }
bind pub -|- !m pub:muteban
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx m }
bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx ub }
bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} { pub:kickban $nk $uh $hn $ch $tx um }
bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
global pkb storehosts
if {$uh ne "Timer"} {
if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
return 0
}
}
if {[string match u* $do]} {
set plus "-"
set nickls [split [string trim $tx]]
} else {
set plus "+"
set reason [join [lrange [split $tx "."] 1 end] "."]
if {$reason eq ""} { set reason "Please change your behaviour thank you." }
set nickls [split [string trim [lindex [split $tx "."] 0]]]
}
set seconds 0
if {[string is digit [lindex $nickls end]]} {
if {[string match {[bm]} $do] || ($do eq "kb")} {
set seconds [expr {[lindex $nickls end] * 60}]
}
set nickls [lrange $nickls 0 end-1]
} elseif {$do eq "m"} { set seconds [expr {$pkb(m_mutetime) * 60}]
} elseif {$do eq "b"} { set seconds [expr {$pkb(b_bantime) * 60}]
} elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}] }
set masktype $pkb(ban_masktype)
if {[string match *m $do]} { set masktype $pkb(mute_masktype) }
foreach nick $nickls {
if {$nick eq ""} { continue }
if {[string match u* $do] && [string match *!*@* $nick]} {
set bmask $nick
if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
set bmask $pkb(mute_maskpre)$bmask
}
if {[ischanban $bmask $ch]} { lappend bmasks $bmask
} elseif {$uh ne "Timer"} {
putserv "NOTICE $nk :$bmask is not a current ban on $ch"
}
continue
}
set aname [string tolower "$nick@$ch"]
if {[onchan $nick $ch]} {
set hand [nick2hand $nick]
if {![string match u* $do]} {
if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
if {[matchattr $hand o|o $ch]} { continue }
}
set chost [getchanhost $nick $ch]
if {[string match {*[bm]} $do]} {
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
lappend dvnicks $nick
}
}
if {[string match k* $do]} { lappend knicks $nick }
} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
if {![string match u* $do]} {
if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
}
set chost [lindex $storehosts($aname) 0]
set bmask [mask:host $nick $chost $masktype $do]
if {[string match u* $do] && ![ischanban $bmask $ch]} {
putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
continue
}
lappend bmasks $bmask
} else { putserv "NOTICE $nk :$nick is not on channel $ch" }
}
if {[info exists dvnicks]} {
while {[set len [llength $dvnicks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "v" $pkb(maxban)]
set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
set dvnicks [lrange $dvnicks $pkb(maxban) end]
} else {
set mode [string repeat "v" $len]
set nicks [join $dvnicks]
set dvnicks ""
}
putquick "MODE $ch -$mode $nicks"
}
}
if {[info exists bmasks]} {
if {$seconds > 0} {
utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
}
while {[set len [llength $bmasks]] > 0} {
if {$len > $pkb(maxban)} {
set mode [string repeat "b" $pkb(maxban)]
set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
set bmasks [lrange $bmasks $pkb(maxban) end]
} else {
set mode [string repeat "b" $len]
set masks [join $bmasks]
set bmasks ""
}
putquick "MODE $ch $plus$mode $masks"
}
}
if {[info exists knicks]} {
while {[set len [llength $knicks]] > 0} {
if {$len > $pkb(maxkick)} {
set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
set knicks [lrange $knicks $pkb(maxkick) end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putserv "KICK $ch $nicks :$reason"
}
}
}
#### protected hosts code
set pkb(phosts) [split [string trim $pkb(phosts)]]
proc mask:host {nick chost masktype do} {
set bmask [maskhost "$nick!$chost" $masktype]
foreach phost $::pkb(phosts) {
if {[string match -nocase $phost $chost]} {
set bmask "*![lindex [split $chost @] 0]@*"
break
}
}
if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
return $bmask
}
#### stored nicks & uhosts code
bind part - * store:hosts
bind sign - * store:hosts
proc store:hosts {nk uh hn ch msg} {
set aname [string tolower $nk@$ch]
set ::storehosts($aname) [list $uh [expr {[unixtime]+900}] $hn]
}
bind kick - * store:kick
proc store:kick {nk uh hn ch target reason} {
set uhost [getchanhost $target $ch]
set hand [finduser $target!$uhost]
store:hosts $target $uhost $hand $ch pkb.tcl
}
bind time - * expire:hosts
proc expire:hosts {mn hr da mo yr} {
global storehosts
set ut [unixtime]
foreach {aname avalue} [array get storehosts] {
if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
}
}