[color:green]; define the max. number of bans in the list[/color]
alias maxbans { return [color:blue]100[/color] }
[color:green]; define the max. number of bans allowed left in the list when clearing[/color]
alias bansallwd { return [color:blue]75[/color] }
[color:green]; you could use the on ban event to check everytime a ban gets added[/color]
on *:BAN:[color:blue]#channel[/color]: {
[color:green]; if the banlist holds 5 open slots or less[/color]
if ($ibl(#,0) >= $calc($maxbans - [color:blue]5[/color])) clearlist $chan
}
[color:green]; or you could use a timer that checks (in this case) every 5 minutes[/color]
on *:CONNECT: {
[color:green]; if the banlist holds 5 open slots or less[/color]
.timerclrclst -o 0 [color:blue]300[/color] if ($!ibl([color:blue]#channel[/color],0) >= $calc($maxbans - [color:blue]5[/color])) clearlist [color:blue]#channel[/color]
}
[color:green]; clear the list[/color]
alias clearlist {
[color:green]; error checking[/color]
if ($1 !ischan) echo -a [color:red]Error in function call to function clearlist - specified argument is not a valid channelname[/color]
else {
[color:green]; set start of loop (end = $bansallwd)[/color]
var %x = $ibl($1,0)
[color:green]; we're gonna be needing this variable later on - it should not exist, but just to be safe...[/color]
unset %b.tmp
while (%x > $bansallwd) {
[color:green]; to prevent a unban flood we're gonna group the unbans in groups of 5[/color]
%b.tmp = $addtok(%b.tmp,$ibl($1,%x),32)
[color:green]; unban when the group hits 5[/color]
if ($numtok(%b.tmp,32) == 5) .mode $1 -bbbbb %b.tmp
[color:green]; clear the variable for the next load[/color]
unset %b.tmp
}
[color:green]; if the bans to be removed isn't a multiple of 5, there will be bans left to undo[/color]
if (%b.tmp) .mode $1 $+(-,$str(b,$numtok(%b.tmp,32))) %b.tmp
[color:green]; always clean up your mess[/color]
unset %b.tmp
}
}