I'm trying to work on this ban protection for my bot. The problem is, I can't get the script to work with wildcard matches. The bot only protects users that have access to the bot, but these users are only protected if a ban on channel is set specific to the hostmask of the user in Users.ini. I'd like some assisstance in modifying this script so that a bot user banned using any type of $address is protected.
Any help is greatly appreciated!
ON *:BAN:*:{
if ($level($banmask) == 100 && $level($nick) != 100) {
mode $chan -b $banmask
}
}
the problem is that 'if ($banmask iswm $ialchan($ulist(*,100,%?),#,1))' is only checking the banmask against the first matching address in the channel, when there could of course be several matching addresses.
the overall method, "for each level 100 address, check if it matches a user in the channel who is affected by the ban", is not efficient in general. a better method can be described as "for each person affected by the ban, check if they are matched by any level 100 address":
on @*:ban:#:{
var %i = 1
while ($ialchan($banmask, #, %i)) {
if ($ulist($v1, 100, 1)) {
mode # -b $banmask
return
}
inc %i
}
}
I have an idea. This may prevail to accomplish the wildcard match:
on !@*:rawmode:#:{
var %b = 1
var %c = *!cDn@*|*2nd@*|*!*3rd@*|*!IDENT@*
while ($gettok(%c,%b,124)) {
if ($wildtok($1-,$v1,1,124)) {
mode # -b $v1
}
inc %b
}
}
on @*:ban:#:{
var %? = 1
while (%? <= $ulist(*,100,0)) {
if ($banmask iswm $ialchan($ulist(*,100,%?),#,1)) {
mode # -b $v1
}
inc %?
}
}
You basically add the keyword of any variation of the wildcard addresses as shown under the rawmode event, divided with a pipe for each one. If the ban mask consists of the keyword, the script will then remove the ban for you.
I would have thought "iswm" would do the trick since both "!ident@.isp.com" and "!ident@.some.weird.name.isp.com" are valid banmasks. The hash tables idea is great, but not practical because at this rate, I'll be adding variations of valid banmasks such as the ones above all day. There are at least 15 authorized users in my bot. :-)
What I can think of at this moment is include an additional feature to add protected addresses in a hash table, along with the rawmode event to catch the wildcard match like so:
on *:exit:{
hsave pro pro
}
on *:start:{
if ($isfile(pro)) {
hmake pro 1000
hload pro pro
}
}
on !@*:rawmode:#:{
if ($hfind(pro,$2,1,w)) {
mode # -b $v1
}
}
on @*:ban:#:{
var %? = 1
while (%? <= $ulist(*,100,0)) {
if ($banmask iswm $ialchan($ulist(*,100,%?),#,1)) {
mode # -b $v1
}
inc %?
}
}
To add those wildcard addresses, use:
/hadd -m pro *!cDn@*.rogers.com
/hadd -m pro *!cDn@*.cpe.net.cable.rogers.com
Jethro: Sorry to trouble you, but I'm still running into a bit of a problem. - Using revised code.
The ban gets removed if set like this:
10:44pm Mode Set: (new-nick123/#LuminolBlue) +b !@clue-306FE3BC.cpe.net.cable.rogers.com
10:44pm Mode Set: (Cat/#LuminolBlue) -b !@clue-306FE3BC.cpe.net.cable.rogers.com
But it doesn't get removed if set like this:
10:46pm -!- Mode Set: (new-nick123/#LuminolBlue) +b !cDn@.cpe.net.cable.rogers.com
10:46pm -!- Mode Set: (new-nick123/#LuminolBlue) +b !cDn@.rogers.com
Or any other format for that matter.
Thanks for your continued help!