mIRC Home    About    Download    Register    News    Help

Print Thread
Is there a way to check for words? #172751 15/03/07 01:41 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
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


GigIRC Network Admin
irc.gigirc.com
Re: Is there a way to check for words? [Re: Trixar_za] #172752 15/03/07 01:53 AM
Joined: Mar 2007
Posts: 139
S
Solo1 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
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

Re: Is there a way to check for words? [Re: Solo1] #172753 15/03/07 02:04 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
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

Last edited by Trixar_za; 15/03/07 02:29 AM.

GigIRC Network Admin
irc.gigirc.com
Re: Is there a way to check for words? [Re: Trixar_za] #172758 15/03/07 04:07 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Is there a way to check for words? [Re: RusselB] #172777 15/03/07 04:05 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
I know, hence the appeal of the challenge smile


GigIRC Network Admin
irc.gigirc.com
Re: Is there a way to check for words? [Re: Trixar_za] #172778 15/03/07 04:17 PM
Joined: Jan 2007
Posts: 259
K
Kardafol Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
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.


Those who can, cannot. Those who cannot, can.
Re: Is there a way to check for words? [Re: Kardafol] #172808 16/03/07 11:34 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
That is what I was looking for, thanks Kardafol smile


GigIRC Network Admin
irc.gigirc.com