mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
I'm trying to use the following regex to catch this sort of nicks which used by the bot. Could you please help why it's not working.

Quote
on 1:join:#channel: {
if ($nick isop $chan) || ($nick isreg $chan) || ($nick isvoice $chan) { return }
if $regex($nick,/[A-Za-z0-9].+(_){4,10}.+[A-Za-z0-9]/gm) { .gline $nick +5d Bot }
}

Nicks are like
WE_____LOVE_YOU
HIDE____IFYOU_____CAN

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
anytime your regex pattern has a comma in it, you must either use
pattern $+ $chr(44) $+ restofpattern
or else put it into a %var like:

//var %nick WE_____LOVE_YOU , %pattern /[A-Za-z0-9].+(_){4,10}.+[A-Za-z0-9]/gm | echo -a $regex(%nick,%pattern)

In your example, you don't need the 'g' or 'm' flags, and if you simply want to match nicks containing at least 4 underscores:

//var %nick WE____LOVE_YOU , %pattern _{4,} | echo -a $regex(%nick,%pattern)

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Thanks maroon works fine i actually added ($nick isreg $chan) which seems to not working properly! i took it out and it works fine

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I suspect 'isreg' worked, but it worked too well. When you're inside the ON JOIN event, all nicks are by definition regular nicks until a later event when some of them are given voice, ops, etc. If you want to exclude eventual ops, you either need to build a list of address masks to exclude, or use a timer that waits a few seconds to give the non-regulars time to be given their status. If using a timer, you'd probably create an alias to be executed a few seconds after the join and pass the nick like: /timer 1 5 aliasname $unsafe($nick) $unsafe($chan)

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Hi Maroon,

Now i would like to add some more nick pattern however, i'm adding it with variables it start triggering for all. Nick Pattern are like

WE_____LOVE_YOU
HI_D_E__IF_YOU_____CAN
FInd|ME|If|You|can

Quote

on @*:join:#channel: {
if ($nick isop $chan) || ($nick isvoice $chan) { return }
var %wnick = $nick , %p1 = /[A-Za-z0-9].+(_){4,10}.+[A-Za-z0-9]/ , %p2 = /^[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_).+/ , %p3 = /[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z].+/
if $regex(%wnick,%p1) || $regex(%wnick,%p2) || $regex(%wnick,%p3) { .gline $nick +5d reason }
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I'm not clear what you mean by 'like' these examples. It sounds like you're not wanting to match specific strings, so can you also include a description of what you're trying to match? My example was matching alphanumeric strings separated by at 4-10 underscores.

If you're wanting to match strings tokenized by _ or | into at least 3 different tokens, you could do something like:

var %a $numtok($nick,$asc(_)) + $numtok($nick,$asc(|))
if (%a >= 3) do stuff

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Hi Maroon,

Thank you for the pattern that will also work but i want make it through regex so that i can match with specific nick patterns. Is it possible to match it with regex ?

Thanks in advance.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I still have no idea what you want. If you want to match 3 literal strings, then don't need to use regex, just use a strings compare. If you are wanting to match a variety of similar nicks, then what's the general rule that would let 1 regex match many different nicks.

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Hi Maroon.

Sorry that you didn't got my point what actually i'm looking for. I don't want 3 literal strings only. What I wanted to do is matching by regex as you can see in my code i have added P1 P2 P3 each of the regex is for different type of nick patterns. In the code it was working for variable p1 & p2 (example is below). Whenever i'm adding p3 it starting to trigger for all the nicks. I want it like i will add more variables like p4, p5.

Quote

Example
if $regex(%wnick,%p1) || $regex(%wnick,%p2) { .gline $nick +5d reason } working fine
if $regex(%wnick,%p1) || $regex(%wnick,%p2) || $regex(%wnick,%p3) { .gline $nick +5d reason } starting to trigger for all why is that


Appreciate if you can help me to let know in which way I can add like more regex pattern in my code.

Thanks

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
What's an example of something I can set %wnick to, which causes the ban when it should not do so?

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Quote
Example
WE_____LOVE_YOU
HI_D_E__IF_YOU_____CAN
FInd|ME|If|You|can
I|want|move|IT_move_IT
Here|I|Go|Catch|Me
P_R_I_N_C_E

Quote

on @*:join:#channel: {
if ($nick isop $chan) || ($nick isvoice $chan) { return }
var %wnick = $nick , %p1 = /[A-Za-z0-9].+(_){4,10}.+[A-Za-z0-9]/ , %p2 = /^[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_).+/ , %p3 = /[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z].+/
if $regex(%wnick,%p1) || $regex(%wnick,%p2) || $regex(%wnick,%p3) { .gline $nick +5d reason }
}

Last edited by SLiprockS; 04/07/20 08:49 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I can confirm that each of these 6 examples does match at least 1 of your 3 regex patterns.
If there are any of these 6 examples which should not match at least 1 of these 3 regex patterns, please indicate which nick, and describe why the nick should not match any of the 3 patterns.

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Dear manroon,

Problem is it also ban ordinary nick if I have all 3 regex pattern indicating
Quote
if $regex(%wnick,%p1) || $regex(%wnick,%p2) || $regex(%wnick,%p3) { .gline $nick +5d reason }

however if i just reduce the %p3 and have the script like
Quote
if $regex(%wnick,%p1) || $regex(%wnick,%p2) { .gline $nick +5d reason }
it works fine match with regex %p1 & %p2 patterns. What's wrong with my regex pattern %p3 whenever I add it my scripts start banning any nicks that join.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Again, which gets to my specific question - I asked you to give me 1 nick that it matches when it shouldn't, but instead you gave me 6 nicks which do match the regex pattern, and which should match.

When I test with the nick foobar, it doesn't match.

So again, give me 1 nick that should not match, but which does match.

//var %wnick = foobar , %p1 = /[A-Za-z0-9].+(_){4,10}.+[A-Za-z0-9]/ , %p2 = /^[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_)+[A-Za-z]+(_).+/ , %p3 = /[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z]+\x7C+[A-Za-z].+/ | if $regex(%wnick,%p1) || $regex(%wnick,%p2) || $regex(%wnick,%p3) { echo -a .gline $nick +5d reason } | else echo -a did not match

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Thank you so much maroon for your time and action. it helps to understand and clear my views. I have resolve the problem which triggering the ban. I had same variable for On nick and on join which causing the ban most of the time smirk. I sent you an private msg long back to get idea of you got some time you can give me a little suggestion

Best


Link Copied to Clipboard