mIRC Home    About    Download    Register    News    Help

Print Thread
#117315 14/04/05 04:04 PM
Joined: Apr 2005
Posts: 2
B
Breno Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
B
Joined: Apr 2005
Posts: 2
how does to ban automatically anybody what join with the identd with a letter and 2 or more varied numbers? Ex: ~a1234, ~x8734, ~z21... ** on !*:join:#:{ if ($regex ...? **

#117316 14/04/05 04:26 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Probably not the best way to do this, but...

on @*:join:#chan: {
var %ident $gettok($gettok($address($nick,0),2,33),1,64)
if ($mid(%ident,2,1) isletter && $mid(%ident,3,20) isnum) {
ban -k $chan $nick
}
}

You can change the ban to be on one of the $address types if you wanted a different type of ban. This should do what you want.

As I said, there may be a better way to do this. This is just what I did while I work. smile


Invision Support
#Invision on irc.irchighway.net
#117317 14/04/05 06:34 PM
Joined: Apr 2005
Posts: 18
B
Pikka bird
Offline
Pikka bird
B
Joined: Apr 2005
Posts: 18
a possible regex solution instead of

if ($mid(%ident,2,1) isletter && $mid(%ident,3,20) isnum) {

is:

if ($regex(%ident,^[a-zA-Z][0-9][0-9]+$)) {

it now takes all digits instead of the first 20 you specified

#117318 14/04/05 06:38 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, I don't really know much about $regex codes. I just put 20 since the likelihood of an ident with over 20 characters is minimal... and even if there were more than 20 characters in it, if you have 20 numbers in a row, then it is most likely a bot anyhow. But $regex is good too. smile


Invision Support
#Invision on irc.irchighway.net
#117319 15/04/05 01:57 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I have a couple of tips for you.

  1. Use the slashes / / to encapsulate the regular expression.

    You might wonder why? Well one of these days you'll be scratching your head when $regex(a,moo) gives 1. If you want to know why it matches, let me know.

  2. U can use the i modifier so that the pattern is case insensitive, so that you can shorten the initial [a-zA-Z] to simply [a-z] (or another variation of that). The expression would be something like /<pattern>/i
    Or if you want only a part of the pattern to be case insensitive you can use the modifiers like this:
    (?<modifiers>)

    Example: /foo(?i)bar(?-i)s/

    Both the foo and s are case sensitive, which means they will only match in that exact representation, so not on mOo etc. bar is however case insensitive, so matches BAR, bAR, etc.

    You can set and unset multiple in one assignment like: /foo(?iS)bar(Ux-iS) s+/
    I won't go into detail about all the meanings of the different modifiers.

  3. You could replace [0-9] with \d, however this is a personal preference, and some might prefer it for easier understanding.

  4. Finally you can use the quantifier {<N>[,N]} to specify how many times you want something to match.

    2 or more digits would be: \d{2,}

    Of course what you did, being \d\d+, or \d\d\d* etc. are just as good.

    In mIRC, commas are the delimiters in an identifier, so the possible comma used in {N,N} would screw up the regex, but we can work around that by putting the expression in brackets (whether that be capturing, uncapturing, lookaround, etc.), then mIRC treats it as part of the pattern, and not as an identifier delimiter.

    Example: /^moo(?:\d{2,5})$/

Note that those tips are not necessarily aimed at you, they might come in handy for anyone taking the first steps in regex.

Greets


Gone.
#117320 18/04/05 10:45 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
In addition (for the purposes of the exact example under discussion in this thread), I would also use $fulladdress (or $address) as the first parameter for $regex(), and switching ! (start-of-identd) for ^ (start-of-string) and @ (end-of-identd) for $ (end-of-string). They are functionally the same here, delimiting the string you wish to check. Alternately, since you are requiring the client to be unidentd'd in this example, you could start with the ~ as your start-of-match character since it cannot appear anywhere else in $fulladdress or $address.

on @*:JOIN:#: if ($regex($fulladdress, /~[a-z](?:\d{2,})@/i)) ban -k # $nick 2 Auto-ban: Spam bot.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#117321 19/05/05 02:22 PM
Joined: May 2005
Posts: 2
F
Bowl of petunias
Offline
Bowl of petunias
F
Joined: May 2005
Posts: 2
Quote:
on @*:JOIN:#: if ($regex($fulladdress, /~[a-z](?:\d{2,})@/i)) ban -k # $nick 2 Auto-ban: Spam bot.


Great script, works like a charm wink BUT what if the ident doesn't start with ~ ? (for example: it's just x1234 instead of ~x1234)

#117322 19/05/05 03:11 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I don't know anything about $regex() but I think this will do what you want, if not there's a few on here that know $regex(). smile

Code:
on @*:JOIN:#: {
  if ($regex($fulladdress, /~[a-z](?:\d{2,})@/i) || $regex($fulladdress, /[a-z](?:\d{2,})@/i)) {
    ban -k # $nick 2 Auto-ban: Spam bot. 
  }
}

#117323 19/05/05 08:11 PM
Joined: May 2005
Posts: 2
F
Bowl of petunias
Offline
Bowl of petunias
F
Joined: May 2005
Posts: 2
Well, it now works with idents that don't start with ~ but it also reacts to idents like xxxx123 (multiple letters before the numbers instead of just one letter). Any idea ?

Thanks !


Link Copied to Clipboard