This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Jan 10, 2022 10:25 am
i took this code caesar wrote from another post to enforce bans to kick in stack
only to find it doesnt seem to stack it sends all found banned nicks to be kicked seperate
Code: Select all
namespace eval enforceBans {
set enforce(max) "4"
set enforce(reason) "Ban %ban set in %from matches your host. You are banned!"
bind mode - "% +b" [namespace current]::enforce
proc enforce {nick uhost hand chan mc ban} {
variable enforce
set reason [string map [list "%from" $chan "%ban" $ban "%who" $nick] $enforce(reason)]
if {![botisop $chan]} { return 0 }
set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
if {[matchstr "*@*mibbit*" "$ban"]} { return 0 }
if {[string match -nocase $ban $::botname]} { return }
foreach n [chanlist $chan] {
if {![matchaddr $ban $n![getchanhost $n $chan]]} continue
if {[isop $n $chan] || [ishalfop $n $chan] || [matchattr [nick2hand $n] "fnmo|fnmo" $chan]} continue
if {[onchan $n $chan]} { lappend kickList($chan) $n }
}
if {[llength $kickList($chan)] > 2} { return }
if {[info exists kickList($chan)]} {
set kickList($chan) [lsort -dictionary $kickList($chan)]
set len [llength $kickList($chan)]
while {$len > 0} {
if {$len > $enforce(max)} {
set users [join [lrange $kickList($chan) 0 [expr {$enforce(max) - 1}]] ,]
set kickList($chan) [lrange $kickList($chan) $enforce(max) end]
incr len -$enforce(max)
} else {
set users [join $kickList($chan) ,]
set len 0
}
after [expr {2*1000*1}] [list putnow "kick $chan $users $reason"]
}
}
}
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Jan 10, 2022 10:37 am
i cant figure why it doesnt stack the nicks to kick
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Jan 10, 2022 10:52 am
Short question: does your server accept multiple kicks in a single line ?
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Jan 10, 2022 11:10 am
yes dalnet does 4 and inspircd 20
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Jan 10, 2022 1:10 pm
i tried with this:
Code: Select all
namespace eval enforceBans {
set enforce(max) "4"
set enforce(reason) "Ban %ban set in %from matches your host. You are banned!"
bind mode - "% +b" [namespace current]::enforce
proc enforce {nick uhost hand chan mc ban} {
variable enforce
variable kickList
set reason [string map [list "%from" $chan "%ban" $ban "%who" $nick] $enforce(reason)]
if {![botisop $chan]} { return 0 }
set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
if {[matchstr "*@*mibbit*" "$ban"]} { return 0 }
if {[string match -nocase $ban $::botname]} { return }
foreach n [chanlist $chan] {
if {![matchaddr $ban $n![getchanhost $n $chan]]} continue
if {[isop $n $chan] || [ishalfop $n $chan] || [matchattr [nick2hand $n] "fnmo|fnmo" $chan]} continue
if {[onchan $n $chan]} { lappend kickList($chan) $n }
}
if {[info exists kickList($chan)]} {
set kickList($chan) [lsort -dictionary $kickList($chan)]
set len [llength $kickList($chan)]
while {$len > 0} {
if {$len > $enforce(max)} {
set users [join [lrange $kickList($chan) 0 [expr {$enforce(max) - 1}]] ,]
set kickList($chan) [lrange $kickList($chan) $enforce(max) end]
incr len -$enforce(max)
} else {
set users [join $kickList($chan) ,]
set len 0
}
after [expr {2*1000*1}] [list putnow "kick $chan $users $reason"]
}
}
}
}
but it doesnt get rid of the nicks that are already kicked it keeps adding the same nicks
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Jan 11, 2022 1:52 am
Code: Select all
namespace eval enforceBans {
variable enforce ; variable kickList
set enforce(max) "4"
#set enforce(reason_single) "Ban %ban set in %from matches your host. You are banned!"
set enforce(reason_multi) "A new ban in %from matches your host. You are banned!"
bind mode - "% +b" [namespace current]::enforce
proc enforce {nick uhost hand chan mc ban} {
variable kickList
if {[matchaddr $ban $::botname]} { return 0 }
if {[matchstr "*@*mibbit*" $ban]} { return 0 }
foreach n [chanlist $chan] {
if {![matchaddr $ban $n![getchanhost $n $chan]]} { continue }
if {[isop $n $chan] || [ishalfop $n $chan]} { continue }
if {[matchattr [nick2hand $n] "fnmo|fnmo" $chan]} { continue }
lappend klist $n
}
if {![info exists klist]} { return 0 }
if {![info exists kickList($chan)]} {
set kickList($chan) $klist
after 2000 [list "[namespace current]::enforce:kick" $chan]
} else { lappend kickList($chan) {*}$klist }
return 0
}
proc enforce:kick {chan} {
variable enforce
variable kickList
if {![botisop $chan] || ![info exists kickList($chan)]} {
array unset kickList $chan
return 0
}
set knicks [lsort -unique -dictionary $kickList($chan)]
unset kickList($chan)
set max $enforce(max)
set reason [string map [list %from $chan] $enforce(reason_multi)]
while {[set len [llength $knicks]] > 0} {
if {$len > $max} {
set nicks [join [lrange $knicks 0 [expr {$max - 1}]] ","]
set knicks [lrange $knicks $max end]
} else {
set nicks [join $knicks ","]
set knicks ""
}
putquick "KICK $chan $nicks :$reason"
}
return 0
}
}
Last edited by
SpiKe^^ on Tue Jan 11, 2022 2:07 pm, edited 1 time in total.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Jan 11, 2022 8:55 am
excellent thanks Spike^^ that seems to do it