If he's going to continue to ignore my questions or advices then fine by me, I'll just mind my day.
Ran a few tests and having multiple +b's while banning one mask caused some errors on my Undernet tests. Still, that there's no need for multiple
when can just use
switch.
Edit: Since I love a good challenge I decided to do my own version of that
stack_ban proc and came up with:
Code: Select all
while {[llength $banList] != 0} {
set len [llength $banList]
if {$len > 6} {
set mode "bbbbbb"
set masks [lrange $banList 0 5]
set banList [lrange $banList 6 end]
} else {
set mode [string repeat "b" $len]
set masks [lrange $banList 0 $len]
set banList ""
}
# do whatever with $mode and $masks
}
Basically it adds the exact amount of b's depending on the amount of masks to ban that are in the list.
Did some testing with:
Code: Select all
set chan "#test"
set banList "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
and works as expected:
MODE #test +bbbbbb 1 2 3 4 5 6
MODE #test +bbbbbb 7 8 9 10 11 12
MODE #test +bbb 13 14 15
And here's the code added in the rp_dobans proc.
Code: Select all
proc rp_dobans {chan uhlist} {
global rp_breason
if {![botisop $chan]} return
set max "6"
set banList ""
set nickList ""
foreach ele $uhlist {
scan $ele {%[^!]!%[^@]@%s} nick user host
set bmask "*!*@$host"
if {[lsearch $banList $bmask] != -1} continue
lappend banList $bmask
lappend nickList $nick
}
while {[llength $banList] != 0} {
set len [llength $banList]
if {$len > $max} {
set mode "bbbbbb"
set masks [lrange $banList 0 [expr $max - 1]]
set banList [lrange $banList $max end]
} else {
set mode [string repeat "b" $len]
set masks [lrange $banList 0 $len]
set banList ""
}
putquick "MODE $chan +$mode $masks" -next
}
flushmode $chan
while {[llength $nickList] != 0} {
putquick "KICK $chan [lindex $nickList 0] :$rp_breason" -next
set nickList [lrange $nickList 1 end]
}
}
Please notice the
max variable that you can change to whatever modes your server allows. That's the only required change for it to do as many modes per line the server allows.
And here's some tests on a bot:
[14:01] <@cez> !hash *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6 *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12 *!*@13 *!*@14 *!*@15 *!*@16 *!*@17
[14:01] * Bot sets mode: +bbbbbb *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6
[14:01] * Bot sets mode: +bbbbbb *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12
[14:01] * Bot sets mode: +bbbbb *!*@13 *!*@14 *!*@15 *!*@16 *!*@17
[14:02] <@cez> !hash *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6 *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12 *!*@13 *!*@14
[14:02] * Bot sets mode: +bbbbbb *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6
[14:02] * Bot sets mode: +bbbbbb *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12
[14:03] * Bot sets mode: +bb *!*@13 *!*@14
[14:03] <@cez> !hash *!*@1 *!*@2 *!*@3
[14:03] * Bot sets mode: +bbb *!*@1 *!*@2 *!*@3
[14:04] <@cez> !hash *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6 *!*@7
[14:04] * Bot sets mode: +bbbbbb *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6
[14:04] * Bot sets mode: +b *!*@7
And here's an additional test with max 4 masks per line, even if server allows 6 (or could be more)
[14:13] <@cez> !hash *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6 *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12 *!*@13 *!*@14 *!*@15 *!*@16 *!*@17
[14:13] * Bot sets mode: +bbbb *!*@1 *!*@2 *!*@3 *!*@4
[14:13] * Bot sets mode: +bbbb *!*@5 *!*@6 *!*@7 *!*@8
[14:13] * Bot sets mode: +bbbb *!*@9 *!*@10 *!*@11 *!*@12
[14:13] * Bot sets mode: +bbbb *!*@13 *!*@14 *!*@15 *!*@16
[14:13] * Bot sets mode: +b *!*@17
Once the game is over, the king and the pawn go back in the same box.