mIRC Homepage
Posted By: Abuser__ Auto answer from txt - 31/12/05 07:54 PM
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
Posted By: MikeChat Re: Auto answer from txt - 31/12/05 08:29 PM
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 }
}
Posted By: RusselB Re: Auto answer from txt - 31/12/05 08:31 PM
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
Posted By: HobophobE Re: Auto answer from txt - 31/12/05 09:19 PM
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.
Posted By: FiberOPtics Re: Auto answer from txt - 01/01/06 01:40 AM
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...
© mIRC Discussion Forums