mIRC Home    About    Download    Register    News    Help

Print Thread
Regex help #186413 22/09/07 12:25 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Will Regex work when they join with nicks like this here?

M_2728816
c_8576494
h_3018346
k_5134810
y_9942033
`M_2728816
`c_8576494
`h_3018346
`k_5134810
`y_9942033

Re: Regex help [Re: Garou] #186415 22/09/07 01:45 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
It can be done with regex, but it can also be done without.

Using your examples:

Code:
On @*:Join:#: {
  var %n = $nick
  $iif(*_* iswm %n, $iif(($gettok(%n,2,95) isnum) && ($len($gettok(%n,2,95)) == 7),ban -k $chan %n 2))
}

Re: Regex help [Re: Garou] #186419 22/09/07 02:17 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It helps when you don't ask the same question in multiple places . You can check there for my response.


Invision Support
#Invision on irc.irchighway.net
Re: Regex help [Re: SladeKraven] #186424 22/09/07 02:59 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
SladeKraven ok cool thx mate, can you please break it down a little so that i can make sure i understand it all?
Like what does this do exacly:
iif(*_* iswm %n, and can I add my kick msg on the same line?


Last edited by Garou; 22/09/07 03:19 PM.
Re: Regex help [Re: Garou] #186430 22/09/07 05:00 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
$iif() is just like IF, but on one line.

/help $iif

$iif(something compared_to something,true,false)

So, //echo -a $iif(1 > 2,It's greater,It's not greater)

That would echo the "false" item, "It's not greater", because the comparison is false.

So he's just checking if *_* iswm the nick and if it is, do something, if not do something different. If you want multiple commands, don't use $iif... just use a normal IF.

Again, you can see 2 examples in your other thread.


Invision Support
#Invision on irc.irchighway.net
Re: Regex help [Re: Garou] #186431 22/09/07 06:03 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Although Riamus2 showed you above how $iif works. I'll break down the code.

On @*:Join:#: {
var %n = $nick
$iif(*_* iswm %n, $iif(($gettok(%n,2,95) isnum) && ($len($gettok(%n,2,95)) == 7),ban -k $chan %n 2))
}

You have your simple on join event, obviously only triggers if you're an operator.

I'm using %n to store the nickname just so we don't keep repeating ourselves with $nick in the if statement.


if (*_* iswm %n)
We check to see if there's anything before and after the underscore.

$iif(($gettok(%n,2,95) isnum) && ($len($gettok(%n,2,95)) == 7),ban -k $chan %n 2)

This only triggers if our if statement is true. As it's true, we then want to compare that anything after the underscore has a numeric value and that the length of the numbers is 7. M_2728816 has 7 numbers after the underscore. If all that is again true, we issue the ban command.

You can add a kick message after the number two:


Code:
On @*:Join:#: {
  var %n = $nick
  $iif(*_* iswm %n, $iif(($gettok(%n,2,95) isnum) && ($len($gettok(%n,2,95)) == 7),ban -k $chan %n 2 <Kick Message Here>))
}


with that said, Riamus2 come up with a regex solution in one of your previous posts.


Re: Regex help [Re: SladeKraven] #186437 22/09/07 07:04 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
thank you very much to both cool

Re: Regex help [Re: Garou] #186448 22/09/07 09:59 PM
Joined: Oct 2006
Posts: 166
B
b1ink Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
/^`?[A-Za-z]_\d{7}$/


Kind Regards, blink
Re: Regex help [Re: b1ink] #186721 25/09/07 03:23 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Can someone please post all the code for this regex kick?

/^`?[A-Za-z]_\d{7}$/

Last edited by Garou; 25/09/07 03:25 PM.
Re: Regex help [Re: Garou] #186722 25/09/07 03:29 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
$regex($nick,/^`?[A-Za-z]_\d{7}$/)


I assume.

Re: Regex help [Re: SladeKraven] #186724 25/09/07 03:34 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Is this right?

On @*:Join:#: {
$regex($nick,/^`?[A-Za-z]_\d{7}$/)
ban -k $chan %n 2 14Drone - Please use another nick when rejoining this channel.
}

Re: Regex help [Re: Garou] #186729 25/09/07 03:43 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
On @*:Join:#: {
if ($regex($nick,/^`?[A-Za-z]_\d{7}$/)) { ban -k $chan $nick 2 14Drone - Please use another nick when rejoining this channel. }
}

Re: Regex help [Re: hixxy] #186730 25/09/07 03:45 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
thx guys.

Last edited by Garou; 25/09/07 03:47 PM.
Re: Regex help [Re: hixxy] #186732 25/09/07 04:01 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
This is working fine, can you edit so that it will kick after let say 4+ to whatever instead of just 7 ?

Re: Regex help [Re: Garou] #186734 25/09/07 04:04 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
On @*:Join:#: {
  if ($regex($nick,/^`?[A-Za-z]_(?:\d{4,})$/)) { ban -k $chan $nick 2 14Drone - Please use another nick when rejoining this channel. }
}

Re: Regex help [Re: hixxy] #186735 25/09/07 04:09 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Perfect thx very much :P