Just curious -simo wrote: ...
but its ok if theres any remaining ban left i ll remove manually
thnx again caesar
Code: Select all
puthelp "MODE $chan -$mode $masks"
Code: Select all
putlog "Clearbans: mode: $mode | masks: $masks"
Let's try this Not using the eggdrop [chanbans $chan] command...simo wrote:is there a way to make it clear all bans
Code: Select all
# clearchanbans.tcl revisited #
set clearbans(max) 6
bind pub o|o !clearbans clear:bans
proc clear:bans {nick uhost hand chan text} {
global clearbans
if {![botisop $chan]} { return 0 }
set clearbans($chan) [list 0]
bind raw - 367 cb:bind:raw
bind raw - 368 cb:bind:raw
putserv "MODE $chan b"
return 0
}
proc cb:bind:raw {from key text} {
global clearbans
lassign [split $text] not chan mask
if {![info exists clearbans($chan)]} { return 0 }
set masks [lassign $clearbans($chan) total]
if {$key == 367} {
lappend masks $mask ; incr total
}
set cnt [llength $masks]
if {$total == 0} {
puthelp "PRIVMSG $chan :$chan Bans list is empty."
} elseif {$cnt == $clearbans(max) || ($cnt>0 && $key==368)} {
set mode [string repeat "b" $cnt]
putserv "MODE $chan -$mode [join $masks]"
set clearbans($chan) [list $total]
} else {
set clearbans($chan) [linsert $masks 0 $total]
}
if {$key == 368} {
unset clearbans($chan)
unbind raw - 367 cb:bind:raw
unbind raw - 368 cb:bind:raw
puthelp "PRIVMSG $chan :Removed $total bans. $chan Bans list is empty."
}
return 1
}
Code: Select all
# clearchanbans.tcl revisited #
set clearbans(max) 6
bind pub o|o !clearbans clear:bans
proc clear:bans {nick uhost hand chan text} {
global clearbans
if {![botisop $chan]} { return 0 }
set clearbans($chan) [list 0]
bind raw - 367 cb:bind:raw
bind raw - 368 cb:bind:raw
putserv "MODE $chan b"
return 0
}
proc cb:bind:raw {from key text} {
global clearbans
lassign [split $text] not chan mask
if {![info exists clearbans($chan)]} { return 0 }
set masks [lassign $clearbans($chan) total]
if {$key == 367} {
lappend masks $mask ; incr total
}
set cnt [llength $masks]
if {$total == 0} {
puthelp "PRIVMSG $chan :$chan Bans list is empty."
} elseif {$cnt == $clearbans(max) || ($cnt>0 && $key==368)} {
set mode [string repeat "b" $cnt]
putserv "MODE $chan -$mode [join $masks]"
set clearbans($chan) [list $total]
} else {
set clearbans($chan) [linsert $masks 0 $total]
}
if {$key == 368} {
unset clearbans($chan)
unbind raw - 367 cb:bind:raw
unbind raw - 368 cb:bind:raw
puthelp "PRIVMSG $chan :Removed $total bans. $chan Bans list is empty."
}
return 1
}
For anyone reading along:d3n wrote:i put this, and i used eggdrop 1.6.21 ! this tcl doesn't work
Code: Select all
set chan [string tolower $chan]
Code: Select all
set clearbans(max) 6
bind pub o|o !clearbans clear:bans
proc clear:bans {nick uhost hand chan text} {
global clearbans
set chan [string tolower $chan]
if {![botisop $chan]} return
set clearbans($chan) {}
bind raw - 367 cb:bind:raw
bind raw - 368 cb:bind:raw
putserv "MODE $chan b"
}
proc cb:bind:raw {from key text} {
global clearbans
switch -- $key {
367 {
lassign [split $text] bot chan mask
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
if {[lsearch $clearbans($chan) $mask] > -1} return
lappend clearbans($chan) $mask
}
368 {
lassign [split $text] bot chan
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
unbind raw - 367 cb:bind:raw
unbind raw - 368 cb:bind:raw
set len [llength $clearbans($chan)]
set total 0
if {$len > 0} {
while {$len > 0} {
if {$len > $clearbans(max)} {
set mode [string repeat "b" $clearbans(max)]
set masks [join [lrange $clearbans($chan) 0 [expr {$clearbans(max) - 1}]]]
set clearbans($chan) [lrange $clearbans($chan) $clearbans(max) end]
incr len -$clearbans(max)
incr total $clearbans(max)
} else {
set mode [string repeat "b" $len]
set masks [join $clearbans($chan)]
incr total $len
set len 0
}
puthelp "MODE $chan -$mode $masks"
}
} else {
puthelp "PRIVMSG $chan :Bans list is empty."
}
puthelp "PRIVMSG $chan :Removed $total bans and list is now empty."
}
}
}
using your version returns me the same error19:04:18 <Cappuccino> Tcl error: invalid command name "wrong # args: should be "clear:bans nick uhost hand text"
19:04:18 <Cappuccino> Tcl error: while executing
19:04:18 <Cappuccino> Tcl error: "clear:bans $_pub1 $_pub2 $_pub3 $_pub4 $_pub5""
Tcl error [cb:bind:raw]: wrong # args: should be "incr varName ?increment?"
[07:50:18] <Jupiter> !clearbans
[07:50:18] * TEST sets mode: -bbbbbbbbbbbb *!*@Test.com-auy.493.44.63.IP *!*@Test.com-119.446.34.43.IP *!*@Test.com-e16.301.24.70.IP *!*@Test.com-3qe.231.01.58.IP *!*@Test.com-iad.991.65.43.IP *!*@Test.com-864.736.99.51.IP *!*@Test.com-k0a.858.08.93.IP *!*@Test.com-nqm.630.94.98.IP *!*@Test.com-gb1.376.93.25.IP *!*@Test.com-r08.604.99.34.IP *!*@Test.com-06c.073.85.59.IP ~q:*!*@Test.com-4cu.725.79.52.IP
[07:50:18] * TEST sets mode: -bbbbbbbbbbbb *!*@Test.com-082.554.45.60.IP *!*@Test.com-5yb.488.57.95.IP ~q:*!*@Test.com-pp2.301.69.59.IP ~q:*!*@Test.com-hfz.047.53.28.IP ~q:*!*@Test.com-ufb.604.06.85.IP ~q:*!*@Test.com-c02.400.26.20.IP ~q:*!*@Test.com-22n.154.50.91.IP ~q:*!*@Test.com-7k1.596.54.91.IP ~q:*!*@Test.com-p8v.513.59.32.IP ~q:*!*@Test.com-827.144.52.27.IP ~q:*!*@Test.com-8p0.118.97.15.IP *!*@Test.com-429.729.78.47.IP
[07:51:05] <Jupiter> !clearbans
Code: Select all
incr total $clearbans(max) $len
Code: Select all
incr total $len
Code: Select all
[08:23:27] Jupiter !clearbans
[08:23:27] * TEST sets mode: -bbbbbbbbbbbb ~q:*!*@Test.com-4cu.725.79.52.IP *!*@Test.com-06c.073.85.59.IP *!*@Test.com-r08.604.99.34.IP *!*@Test.com-gb1.376.93.25.IP *!*@Test.com-nqm.630.94.98.IP *!*@Test.com-k0a.858.08.93.IP *!*@Test.com-864.736.99.51.IP *!*@Test.com-iad.991.65.43.IP *!*@Test.com-3qe.231.01.58.IP *!*@Test.com-e16.301.24.70.IP *!*@Test.com-119.446.34.43.IP *!*@Test.com-auy.493.44.63.IP
[08:23:27] * TEST sets mode: -bbbbbbbbbbbb ~q:*!*@Test.com-hfz.047.53.28.IP ~q:*!*@Test.com-pp2.301.69.59.IP *!*@Test.com-5yb.488.57.95.IP *!*@Test.com-082.554.45.60.IP *!*@Test.com-429.729.78.47.IP ~q:*!*@Test.com-8p0.118.97.15.IP ~q:*!*@Test.com-827.144.52.27.IP ~q:*!*@Test.com-p8v.513.59.32.IP ~q:*!*@Test.com-7k1.596.54.91.IP ~q:*!*@Test.com-22n.154.50.91.IP ~q:*!*@Test.com-c02.400.26.20.IP ~q:*!*@Test.com-ufb.604.06.85.IP
[08:23:27] * TEST sets mode: -b *!*@Test.com-i49.482.76.85.IP
[08:23:27] * &TEST Removed 25 bans and list is now empty.