mIRC Home    About    Download    Register    News    Help

Topic Options
#138458 - 31/12/05 07:54 PM Auto answer from txt
Abuser__ Offline
Babel fish

Registered: 21/04/05
Posts: 53
So as the subject says I am trying to make a script that will auto answer the question. I know some things with $gettok but here is my problem:

Users says: Hi
Bot answers: Hello

there is a lot of these questions and answers in my txt file. They are separated by *. The data.txt file looks like that:
Hi*Hello
Come*Go
Away*Here
and so on..

On the left side is the text that user says, on the right is the answer wich bot should say. I dont know how to search the data.txt file and return the match line to use $gettok and return the answer. I have tried /help $read but it didn't help much.
Thanks for any help and happy new year wink

Top
#138459 - 31/12/05 08:29 PM Re: Auto answer from txt
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
help for $read says that $read(filename,s,word) will find a line BEGINNING with the word and return the info After the word

so
on *:text:!bot *):#channel:{
var %inputword = $$2
var %reply = $read(filename,s,%inputword)
if (%reply) { msg $chan %reply }
}

flood protection added:
on *:text:!bot *):#channel:{
if (%antiflood) { return }
set -u10 %antiflood 1
var %inputword = $$2
var %reply = $read(filename,s,%inputword)
if (%reply) { msg $chan %reply }
}


Edited by MikeChat (31/12/05 09:40 PM)

Top
#138460 - 31/12/05 08:31 PM Re: Auto answer from txt
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Code:
 on *:text:*:#:{
.msg $chan $reply $1-
}
on *:action:*:#:{
describe $chan $reply $1-
}
alias reply {
$nickvar %entry = $1-
while %entry {
var %answer = $gettok($read(data.txt,w,$gettok(%entry,1,32)),-1,42)
return $iif(%answer,$v1)
var %entry = $remtok(%entry,$gettok(%entry,1,32),1,32)
}
}
 


Warning...if this is used as is, by a lot of people, the bot might flood the server


Edited by RusselB (31/12/05 08:32 PM)

Top
#138461 - 31/12/05 09:19 PM Re: Auto answer from txt
HobophobE Offline
Ameglian cow

Registered: 23/12/02
Posts: 29
You could use mIRC's built in flood protection which will queue your own messages to prevent flooding, or add to the script a routine to prevent flooding. To do the latter would be something like on the triggering add a number to a variable that is set to expire after a given time. Also, the trigger will check to see if the variable has already exceeded a determined value.

example:

alias noflood {
if (%flood > 4) { return $true }
if (!%flood) { set -u15 %flood 1 }
else { inc %flood }
}

on *:text:*:#:{
if (!$noflood) {
[rest of the trigger code here]
}
}

The benefit of using a single alias instead of adding similar code to a number of triggers is that it will prevent several different auto-response commands from a bot or such being able to be exploited to flood it off. That said, it is still probably preferable to use mIRC's built in function for this, as the responses will still occur, they will merely be offset in time to prevent flooding.

Top
#138462 - 01/01/06 01:40 AM Re: Auto answer from txt
FiberOPtics Offline
Hoopy frood

Registered: 05/02/04
Posts: 2019
Loc: Leuven, Belgium
So basically, you are creating a cheat system? That doesn't really go along well with fair-play does it? I've played a lot of trivia in the past, and if there's one thing everyone hates with a passion, it is cheaters. Followed closely by lag...
_________________________
Gone.

Top