mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2005
Posts: 6
D
duklaa Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2005
Posts: 6
What is the syntax for combining multiple events for which I want to take the same action?

e.g. I want to automatically reply with "Foo" to any of the following TEXT events:
what is your name
what is ur name
wut is your name
wut is ur name
...so on

all need to respond with "foo"

I haven't found how I could specify this succintly in mirc syntax.

On a related note what is the escape character? For example, if I include a question mark in a TEXT event ("What is your name?" doesn't work but "what is your name*" works).

Thanks in advance

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
On *:Text:* is your name*:?: { msg $nick foo }


What is your name? should work but it will only match those exact words. You need to be specific with wildcards. what is your name* will match the following:

what is your name?
what is your names
what is your namex
..so on.

On *:Text:* is your name*:?: { msg $nick foo } that matches any word before is, whether it be what/wut/wat/wot etc.

-Andy

Joined: May 2005
Posts: 6
D
duklaa Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2005
Posts: 6
Yes. I think I wasn't clear enough in what I wanted to ask.

* is your name * is too broad of a match. For instance,

I want to match "wut/wot/what is your name" but NOT "tell me your name". The only way I know of to do this right now is to write three separate remotes:
wut is your name*
what is your name*
wot is your name*

Is there a more elegant approach?

Last edited by duklaa; 12/05/05 05:33 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Examples for a query request of your name:

Using your specific text values:
Code:
on *:text:*:?: {
  if (what is your name isin $1- || what is ur name isin $1- || wut is your name isin $1- || wut is ur name isin $1-) {
    msg $nick Foo
  }
}


Using wildcards (may not always be as accurate):
Code:
on *:text:*:?: {
  if (what is * name* iswm $1- || wut is * name* iswm $1-) {
    msg $nick Foo
  }
}


|| is OR

If you want to include a ? in that, use $+ $chr(63). Example:
Code:
on *:text:what is your name $+ $chr(63):?: {
  commands
}


$+ combines two items without a space between them. $chr(63) is a question mark. Otherwise, ? is used as a single-character wildcard.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Here's a regex solution...

on $*:TEXT:*:m/(what|wut|whot) is (your|ur|yor) name\?/iS:#channel:msg $chan foo

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
At some point, I'll take the time to learn $regex. I figured there was a simple way to do it with $regex. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
The m/ is unnecessary: it's used when you wish to change the / / to some other character. For example, m/irc/iS might become m&rc&iS. Also, you need to remove the :*: in the matchtext position if you're going to supply a regex matchtext. Here's how I would do your version:

on $*:TEXT:/w(h(a|o)|u)t is (yo)?u?r name\?/iS:#: msg # foo


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Right, read over the m being optional in the helpfile.
I didn't know you could use it to change the // in mIRC too, knew it's possible in Perl...

As for the extra :* let's blame that on a faulty keyboard grin

Just hate that it's impractical to use (?:) to get non-capturing groups, using (? $+ $chr(58) $+ doesn't really help in make a nicer pattern crazy

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
You have already been given a regex which works fine, all the way up untill you want to make your own, and then start getting it wrong lol (like me)

a quick way is this

alias -l name.is.foo { msg $iif($chan,$chan,$nick) Foo }
on *:text:what is your name:*:{ name.is.foo }
on *:text:what is ur name:*:{ name.is.foo }
on *:text:wut is your name:*:{ name.is.foo }
on *:text:wut is ur name:*:{ name.is.foo }
on *:text:etc.:*:{ name.is.foo }

you just keep adding a line for each one you want


Link Copied to Clipboard