mIRC Home    About    Download    Register    News    Help

Print Thread
Need help #242322
03/07/13 09:21 PM
03/07/13 09:21 PM
Joined: Jul 2013
Posts: 4
K
KingJoffrey Offline OP
Self-satisified door
KingJoffrey  Offline OP
Self-satisified door
K

Joined: Jul 2013
Posts: 4
Hello, first of all I am a total noob when it comes to scripting or anything related but I wanted to write a script or get some help with it.

So basically what I want is sort of like a trivia bot but not really. I want users to be able to type a command such as !V test1 test2 test3 where it will search for keywords in any questions/text it finds like test1, test2 and test3 and then relay the results when the user uses !V.

I have a long list of questions/answers but I don't want people to guess or try to answer, I want the bot to relay both the question and answer all in one message when somebody uses the !V search for keywords function. If it helps the list is on a website/wiki board but I don't know if it's possible to somehow link it in the script.

Thanks for any help you can offer me.

Re: Need help [Re: KingJoffrey] #242326
04/07/13 06:28 PM
04/07/13 06:28 PM
Joined: Dec 2002
Posts: 86
California, USA
Zmodem Offline
Babel fish
Zmodem  Offline
Babel fish

Joined: Dec 2002
Posts: 86
California, USA
This is absolutely possible, but it's not very simple. First, you simply need to create a bot script that watches for the !V typing event from users, such as:

Code:
ON *:TEXT:!V *:#: {
 ; Everything you want the bot to do goes in here
}


You can set the '#channelname' to anything, but if you want the bot to respond to all requests in any channel, you would simply leave it as '#'.

The next thing on your list is comparing a search query within a set of text and whether or not the query exists. This is fairly simple to do as well:

Code:
ON *:TEXT:!V *:#: {
 var %nickname = $nick, %string = $1-, %query = $gettok(%string,1,45), %searchin = $gettok(%string,2-,45)

 if (%query iswm %searchin) {
    .msg # %nickname $+ : " $+ %query $+ " was found in " $+ %searchin $+ ".
    return
 }
 .msg # %nickname $+ : Search query " $+ %query $+ " was not found in your request: " $+ %searchin $+ ".
}


Now, what you're trying to accomplish is most likely even more complicated than this, such as highlighting/making-bold the spots in the search text where the query matches, and your request to have it search a website. You will want to read up on sockets and how to download binary information and strip html tags as well.

Good luck!


-Zmodem
Re: Need help [Re: Zmodem] #242334
05/07/13 03:58 PM
05/07/13 03:58 PM
Joined: Jul 2013
Posts: 4
K
KingJoffrey Offline OP
Self-satisified door
KingJoffrey  Offline OP
Self-satisified door
K

Joined: Jul 2013
Posts: 4
Hmm while I absolutely appreciate the help I think it would be a little too complicated for me then lol. Forget the website part then, would it be easier to input the text myself that I want to be searched or have some sort of a text file for it to search within? Thanks for helping!

And if it is a text file would all users be able to search it?

Re: Need help [Re: KingJoffrey] #242340
05/07/13 11:13 PM
05/07/13 11:13 PM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Deega  Offline
Vogon poet
D

Joined: Oct 2012
Posts: 164
Try using /filter to find the matches in the txt file, then /play to send them to the channel.
Code:
on *:text:!V *:#:{
  filter -ffg file.txt tmpresult.txt / $+ $replace($2-,$chr(32),|) $+ /i
  .play # tmpresult.txt
  .remove tmpresult.txt
}
The above searches in "file.txt" so change that part to whatever your file is named.

/help /filter
/help /play

Re: Need help [Re: Deega] #242371
08/07/13 05:06 PM
08/07/13 05:06 PM
Joined: Jul 2013
Posts: 4
K
KingJoffrey Offline OP
Self-satisified door
KingJoffrey  Offline OP
Self-satisified door
K

Joined: Jul 2013
Posts: 4
I don't think I want to play the file, I just want certain users (half-ops/ops) to be able to search through text. I guess this is called a trigger script? For example ...

[user] !V batman 1989
Who played the role of Batman in the 1989 “Batman” movie? Michael Keaton

It will reply with anything that has 1989 and batman in a line. I already have a long list of these type of questions/answers that I want certain users (half-ops/ops) to be able to search when using the !V command. Do I save them in a text file and have it search through that or do I input the list in the script somewhere? Thanks for your help.

Re: Need help [Re: KingJoffrey] #242381
09/07/13 04:31 AM
09/07/13 04:31 AM
Joined: Jul 2013
Posts: 4
K
KingJoffrey Offline OP
Self-satisified door
KingJoffrey  Offline OP
Self-satisified door
K

Joined: Jul 2013
Posts: 4
Code:
on *:TEXT:!V Elizabeth Banks:#:{ /msg $chan Elizabeth Banks played Beth. Banks portrays __ in the "Hunger Games" films Effie Trinket }


So I've got this when a user types !V elizabeth banks the bot will reply with :

[BOT] Elizabeth Banks played Beth. Banks portrays __ in the "Hunger Games" films Effie Trinket

But how do I get it so it matches any string of keywords in any order in that sentence? For example any one of these commands will trigger the bot to reply ...

!V elizabeth
!V banks
!V hunger games
!V effie trinket