|
Breno
|
Breno
|
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 ...? **
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
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. 
|
|
|
|
BarGarth
|
BarGarth
|
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
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
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. 
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
I have a couple of tips for you. 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. 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. You could replace [0-9] with \d, however this is a personal preference, and some might prefer it for easier understanding. 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
|
|
|
|
Joined: Dec 2002
Posts: 1,253
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,253 |
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.
|
|
|
|
FreekOne
|
FreekOne
|
on @*:JOIN:#: if ($regex($fulladdress, /~[a-z](?:\d{2,})@/i)) ban -k # $nick 2 Auto-ban: Spam bot. Great script, works like a charm  BUT what if the ident doesn't start with ~ ? (for example: it's just x1234 instead of ~x1234)
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
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(). 
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.
}
}
|
|
|
|
FreekOne
|
FreekOne
|
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 !
|
|
|
|
|