mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2011
Posts: 52
E
eawedat Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Nov 2011
Posts: 52
hey all,,

Php Code:
on *:text:*hi*:#: { } 


with mentioned event above,, How could I use multiple words?
for example :-

Php Code:

on *:text:*hi*|*welcome*|*hello*|more_words.........:#: { }
 


I am not interested typing in many events.
I need it in same event.

thanks.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You don't need it in the same event, you want it in the same event. There are a few ways to do this, if you want it that badly:

#1. Match * in the matchtext and test the words inside of the event:

Code:
on *:TEXT:*:#: {
  if (hi isin $1-) do something
  else if (welcome isin $1-) do something
}


If you want all the words to do the same thing, you can use compound ifs like: if (hi isin $1- || welcome isin $1- || ...) dosomething

#2. The easier but more advanced way is to use regex in the matchtext. You were using a similar syntax in your example:

Code:
on $*:TEXT:/hi|welcome|hello|other|words/:#:do something


Note that you need the "$" prefix to indicate that the matchtext is regex, and // is the regex boundary, which is also necessary. The rest is just regex syntax. If you don't know regular expressions, you can learn about them at http://regular-expressions.info

As a sidenote, you can also do this with multiple events by defining an alias to handle the event body instead of duplicating the blocks as you are probably imagining you'd have to do:

Code:
on *:TEXT:*hi*:#:evt_handler
on *:TEXT:*welcome*:#:evt_handler
on *:TEXT:*hello*:#:evt_handler
alias evt_handler {
  do_something with $1- ...
  ...
}


Yes, it's not as nice, but it's not as bad as you think either.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can group hi and hello together if using regex is your intention:
Code:
/h(i|ello)|welcome|other|words/iS
First, make sure you specify the /i modifier, because regex is case-sensitive. Without it, it won't match for uppercase. The /S modifier is mIRC's built-in modifier to strip control codes. Finally, you must prefix the text event with $ to tell mIRC that your text event is a regex.
Quote:
on $*:text:/...


Link Copied to Clipboard