mIRC Home    About    Download    Register    News    Help

Print Thread
#86981 15/06/04 08:09 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
How can I have the trigger of like
on 1:TEXT:*word*:#:commands
be read from a text file so that *word* could be any word in the txt file?

#86982 15/06/04 08:45 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Create an INI file with the following content:
  • [hashtable]
    *word1*=
    *word2*=
    *word3*=
When the bot joins its channel, the INI file will be loaded into the memory:
  • On me:*:join:#channel:{
    if $hget(keys) { hfree keys }
    hmake keys
    hload -i keys file.ini
    }
Whenever somebody speaks in the channel, the items in the memory will me matched against the text, to see if it contains any of the triggers you defined:
  • On *:text:$($hfind(keys,$1-,1,W)):#channel:{
    msg # $matchkey matched your text.
    }

#86983 15/06/04 08:49 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
Quote:
On *:text:$($hfind(keys,$1-,1,W)):#channel:{
msg # $matchkey matched your text.
}


what does $matchkey return?

#86984 15/06/04 08:53 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
$matchkey holds the value that $hfind() returned, i.e. the trigger that matched the sentence in question.

#86985 15/06/04 09:00 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
Wow, it works great Online, thanks!

#86986 15/06/04 09:06 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
You're welcome

#86987 15/06/04 09:16 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
I have a question, say I was to make a dialog, how would I fix it where the user could add/remove words to the trigger list (file.ini)

//edit\\ I have no experience with writing raw dialog code
I use to use a stuido editor thing, but dont have it anymore and i've frogotten where to get it and the name of it..kinda sad//edit\\

Last edited by LostServ; 15/06/04 09:20 PM.
#86988 15/06/04 10:23 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Try this code: http://members.lycos.co.uk/onln/files/keywords.txt

Type /editor to bring the keywords dialog.

Note that file [keys.txt] has a different format now:
  • *word1*<LF><LF>*word2*<LF><LF>*word3*<LF><LF>
But it doesn't really matter because all editing will be done from the dialog.

#86989 15/06/04 10:26 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Btw, the Dialog Studio and a couple of other editors are available here.


Link Copied to Clipboard