mIRC Homepage
Posted By: Trixar_za Is there a way to check for words? - 15/03/07 01:41 AM
I am trying to write an Smart AI for my IRC bot, only trouble is that I have no idea how to make the bot match per WORD rather than scan the whole text for nearest match. I also want to scan all the words in a sentance for matches.

Like 'hi' in the word high triggers the script and I don't want that. Even a exact matching method would help smile

Any help would be appechiated smile
Posted By: Solo1 Re: Is there a way to check for words? - 15/03/07 01:53 AM
I dont really script but looking at the help file i thought maybe $istok would help.
example.

Code:
on *:text:*:#: if ($istok($1-,hi,32)) { ....


and what about on *:text:*hi*:#: if you are only looking for one word and dont have to parse alot of if statements that maybe an option
Posted By: Trixar_za Re: Is there a way to check for words? - 15/03/07 02:04 AM
I tried the 'on *:text:*word*:#:' method once, but it gets bulky and slow and stops working correctly after you add a certian amount.

Was planning something a little more than one word, but yeah I'll try out the $istok method and see with what I can come up with.

edit -- On some reflection, I think maybe a hybred of the two methods could be used to reach my goal, but expect to hear from me again if it fails :P
Posted By: RusselB Re: Is there a way to check for words? - 15/03/07 04:07 AM
As a note, AI scripts for mIRC have been suggested and attempted before, but (to my knowledge) no one has ever written one that is complete, due to various limitations of the mIRC program.
Posted By: Trixar_za Re: Is there a way to check for words? - 15/03/07 04:05 PM
I know, hence the appeal of the challenge smile
Posted By: Kardafol Re: Is there a way to check for words? - 15/03/07 04:17 PM
You could use:
Code:
$regex(name,a few words,/\b(word|otherword|anotherword)\b/)

\b in regex is a word boundary if I'm correct (will match 'nothing' in: "there is nothing!", where $istok wouldn't).
Also, you can use $regml(name,1) to get the word matched (to save some CPU cycles), and $regml(name,1).pos to get the position of the match.
Posted By: Trixar_za Re: Is there a way to check for words? - 16/03/07 11:34 AM
That is what I was looking for, thanks Kardafol smile
© mIRC Discussion Forums