Code: Select all
namespace eval MassKick {
# self explanatory
set mass(limit) "1:5"
set memo(mass) "MSG"
set memo(bot) "MSG"
# don't count or do anything to people with local/global friend flag or whatever you wish
set mass(friends) "f|f"
# don't edit below this line
setudef flag massKick
setudef str massKicker
setudef str massCount
# binds
bind kick * * [namespace current]::kicked
bind part - * [namespace current]::remove
bind sign - * [namespace current]::remove
bind nick - * [namespace current]::nickCh
# AOP removal and memo
proc takeAction {chan nick pos} {
dropAOP $chan $nick "1"
doThis "2" $chan $nick $pos
}
# bot kicked
proc botKicked {chan nick} {
dropAOP $chan $nick "2"
resetChan $chan
}
# reset
proc resetChan {chan} {
channel set $chan massKicker {}
channel set $chan massCount {}
}
# remove AOP, deop and send memo
proc dropAOP {chan nick act} {
variable memo
switch -- $act {
"1" {
set message [string map -nocase [list "%chan" "$chan" "%nick" "$nick"] $memo(mass)]
}
"2" {
set message [string map -nocase [list "%chan" "$chan" "%nick" "$nick"] $memo(bot)]
}
}
putserv "Chanserv aop $chan del $nick"
putserv "Chanserv deop $chan $nick"
putserv "Memoserv sendsop $chan $message"
}
# triggers:
# 1 - add, 2 - remove, 3 - replace nick, 4 - replace count
proc doThis {act chan nick {pos ""} {count ""} {newNick ""}} {
set massKicker [channel get $chan massKicker]
set massCount [channel get $chan massCount]
switch -- $act {
"1" {
lappend massKicker $nick
lappend massCount 1
}
"2" {
set massKicker [lreplace $massKicker $pos $pos]
set massCount [lreplace $massCount $pos $pos]
}
"3" {
set massKicker [lreplace $massKicker $pos $pos $newNick]
}
"4" {
set massCount [lreplace $massCount $pos $pos $count]
}
}
channel set $chan massKicker $massKicker
channel set $chan massCount $massCount
}
# triggers:
# 1 - part & sign, 2 - nick change
proc eventThis {event chan nick {newNick ""}} {
set massKicker [channel get $chan massKicker]
if {$nick ni $massKicker} return
set pos [lsearch $massKicker $nick]
switch -- $event {
"1" {
doThis "2" $chan $nick $pos
}
"2" {
doThis "3" $chan $nick $pos "0" $newNick
}
}
}
# part & sign
proc remove {nick uhost handle chan {text ""}} {
if {![channel get $chan massKick]} return
if {[isbotnick $nick]} {
resetChan $chan
} else {
eventThis "1" $chan $nick
}
}
# nick
proc nickCh {nick uhost handle chan newnick} {
if {![channel get $chan massKick]} return
if {[isbotnick $nick]} return
eventThis "2" $chan $nick $newNick
}
# kick
proc kicked {nick uhost hand chan target reason} {
if {![channel get $chan massKick]} return
variable mass
if {[matchattr $hand $mass(friends) $chan]} return
if {[isbotnick $nick]} return
if {$nick eq "Chanserv"} return
if {[isbotnick $target]} {
botKicked $chan $nick
return
}
set massKicker [channel get $chan massKicker]
if {$nick ni $massKicker} {
doThis "1" $chan $nick
return
}
set pos [lsearch $massKicker $nick]
set massCount [channel get $chan massCount]
set count [lindex [split $massCount] $pos]
set info [split $mass(limit) :]
if {$count >= [lindex $info 0]} {
takeAction $chan $nick $pos
return
} else {
incr count
}
utimer [lindex $info 1] [list [namespace current]::doThis "2" $chan $nick $pos]
doThis "4" $chan $nick $pos $count
}
}
below is example
nick in aop list : A
masskicker joins with nick B using A access, tcl unable to detect whose access is it using thus unable to delete the access. It still sends memo to channel but using B nick. It should del A access and send memo as A access been deleted for attempt of masskick.
So things to do will be able to distinguish access of any nick joining the channel and act accordingly should the need arise. thanks in advance