Level-based Ban Protection

By LuminolBlue on Nov 26, 2011

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
   }
}

Comments

Sign in to comment.
Jethro   -  Nov 28, 2011

Yeah, it didn't cross my mind to consider a code that way. Thank you.

I do know that $banmask by itself is wildcard prone. jaytea's example above should get the job done right.

 Respond  
jaytea   -  Nov 28, 2011

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
  }
}
 Respond  
LuminolBlue   -  Nov 27, 2011

Okay, thank you for all your help. I greatly appreciate it. I'll see if I can play around with it a little and get it to work how I want. :-)

 Respond  
Jethro   -  Nov 27, 2011

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.

 Respond  
Jethro   -  Nov 27, 2011

I'm not sure what can be done about that. The $ialchan() identifier will match mIRC's internal address list, which is merely able to identify nine address types stated above.

 Respond  
LuminolBlue   -  Nov 27, 2011

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. :-)

 Respond  
Jethro   -  Nov 26, 2011

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
 Respond  
Jethro   -  Nov 26, 2011

The script will only recognize these ban types:

0: *!user@host
1: *!*user@host
2: *!*@host
3: *!*user@*.host
4: *!*@*.host
5: nick!user@host
6: nick!*user@host
7: nick!*@host
8: nick!*user@*.host
9: nick!*@*.host
 Respond  
LuminolBlue   -  Nov 26, 2011

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!

 Respond  
FordLawnmower   -  Nov 26, 2011
<>/<>><>/>
 Respond  
Jethro   -  Nov 26, 2011

My error. This one is tested should do it:

on @*:ban:#:{
  var %? = 1
  while (%? <= $ulist(*,100,0)) {
    if ($banmask iswm $ialchan($ulist(*,100,%?),#,1)) {
      mode # -b $v1
    }
    inc %?
  }
}
 Respond  
LuminolBlue   -  Nov 26, 2011

Hmmm... doesn't seem to be working at all.

8:07pm -!- Mode Set: «new-nick123/#LuminolBlue» +b !cDn@.rogers.com

And my bot doesn't remove the ban like he's supposed to because I am level 100. Levels in my bot are entered like this: 100:Nick!@.isp.com. Perhaps this will help?

 Respond  
LuminolBlue   -  Nov 26, 2011

Thank you so much, Jethro. I greatly appreciate your help!

 Respond  
Jethro   -  Nov 26, 2011
on @*:ban:#:{
  var %? = 1
  while (%? <= $ulist(*,100,0)) {
    if ($ialchan($ulist(*,100,%?),#,1).nick isban #) {
      mode # -b $banmask
    }
    inc %?
  }
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.