The idea is to use $hfind, with either regex or just wildcard matching, but regex allow you to match in a better way.

If you plan on having a lot of keywords, you should use an hash table where each item is an unique name and where the data is the expression (we can't use the item name for the expression in case you want to use spaces in your expression, see the example below).

So, supposing keyword are actually words in your case, with a regular expression it could be useful to use \b, which match at words boudaries, it doesn't match characters, it makes sure we are 'around' a word, we use () to capture the actual keyword to be able to get it later:

/hmake keywords
/hadd keywords 1 /\b(word1)\b/
/hadd keywords 2 /\b(word2)\b/
/hadd keywords 3 /\b(word3 word4)\b/

And now, inside an on text event, you can do:

Code:
on *:text:*:#mychannel:{
var %t $1-
noop $hfind(keywords,$1-,0,R,noop $regex(%t,$hget(keywords,$1)) [ $(|) ] msg $chan the keyword $qt($regml(1)) was matched).data
}


Calling $hfind that way tell mIRC to try each data in the hash table as the regular expression against the value $1-, which correspond to the message.

Quote:
[15:24:17] <@Aphrodite> word1 word2 word3 word4
[15:24:17] <@Ouims> the keyword "word3 word4" was matched
[15:24:17] <@Ouims> the keyword "word1" was matched
[15:24:17] <@Ouims> the keyword "word2" was matched


If you are not familiar with regular expression, you can use simple wildcard expression but you cannot successfuly match a 'word' with them. To do so you just change the R to W in the $hfind call and you change your expresion to wildcard expression like *word1*.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel