mIRC Home    About    Download    Register    News    Help

Print Thread
#138458 31/12/05 07:54 PM
Joined: Apr 2005
Posts: 53
A
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
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

#138459 31/12/05 08:29 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
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 }
}

Last edited by MikeChat; 31/12/05 09:40 PM.
#138460 31/12/05 08:31 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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

Last edited by RusselB; 31/12/05 08:32 PM.
#138461 31/12/05 09:19 PM
Joined: Dec 2002
Posts: 29
H
Ameglian cow
Offline
Ameglian cow
H
Joined: Dec 2002
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.

#138462 01/01/06 01:40 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.

Link Copied to Clipboard