|
| Author |
Message |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Thu Jan 15, 2004 9:09 pm Post subject: |
|
|
Trigger is a chat module that uses the familiar trigger/response system. I took the existing system that many of you have used with the old wiredbots code and made it easier to user and more powerful.
Trigger responses are stored in a text file as usual. The first line of the text file is the version number, followed by the trigger/response lines, which are separated with ### for readability. The first part is the trigger that is matched against a user's message, the second part is the list of responses to that trigger.
I've included a simple triggers file, called direct_responses.txt. You can modify this to suit your bot. It also contains the NEW service triggers examples. These are triggers that call bot services for the response. I've included the Bart Simpson, Fortune and SimpleStatement services in the file. So your bot will automatically handle user messages like tell me a fortune, give me a bart simpson saying and what is a bird? and what is a car?.
To use the module:
| Code: | | use Trigger;<br />my $trigger = new Trigger(); |
Then, wherever you respond to user input, say in your AIM's on_im function or in your thought() function, add this code:
| Code: | | $reply = $trigger->processMessage( $username, $message ); |
This might return an empty string for $reply, in which case you should add your own reply or perhaps use the Blab module to generate a random reply. In fact this module works just like the Blab module and they are designed to work together. First use Trigger to see if we have a direct response to the user's message; if not, use Blab to get a random response. And Trigger doesn't affect the learning abilities of Blab.
Bugs or problems, let me know. |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Mon Sep 26, 2005 5:20 pm Post subject: |
|
|
Can this work on Mayabot? I have tried but it does not want to go. I do not get any erros, Maya just shuts down when I send an IM to my bot.
Many Thanks,
TrUz |
|
| Back to top |
|
 |
zander God Like

Joined: 14 Jan 2004 Posts: 540 Location: england
 
|
Posted: Tue Sep 27, 2005 8:22 am Post subject: |
|
|
| hey TrUz, the trigger module will work with every bot i would think if you read over the instructions again and try again it may work although it is the same as the old one in the way of setting up so if you download a bot say white warrior version 1 that has the trigger module in it... have a look how it is done and copy it |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Tue Sep 27, 2005 9:51 am Post subject: |
|
|
Yeah that is actually what I did do. But I came a bit stuck as I could not find this bit of code in White Warrior:
| Code: | | $reply = $trigger->processMessage( $username, $message ); |
I will give it another bash later. When I get home, cheers.
TrUz |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Tue Sep 27, 2005 11:53 am Post subject: |
|
|
| TrUz wrote: | Yeah that is actually what I did do. But I came a bit stuck as I could not find this bit of code in White Warrior:
| Code: | | $reply = $trigger->processMessage( $username, $message ); |
I will give it another bash later. When I get home, cheers.
TrUz |
It's possible that WW uses different variables besides $reply and $trigger (variable names aren't important in Perl).
i.e. this would work just the same:
$red = $blue->processMessage ($soandso, $whatTheySaid);
Assuming that those four variables contain the right values.
Just search WW for "processMessage" as that's the part that absolutely must be exact, unless they modded Trigger which isn't likely the case. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Tue Sep 27, 2005 1:53 pm Post subject: |
|
|
Cheers Cer, found it now. I will give it a bash now I know how White Warrior is doing it.
EDIT: Got it going, many thanks Cer. For those that are interested, here is how I done it. Obviously install Trigger.pm and direct_responses.txt in the Lib folder and edit the direct_resposes to point to the text file in the Lib folder.
Now you need to change the reply sub in bot.pl to:
| Code: |
sub reply {
my $victim = shift;
my $msg = shift;
my $trigger = new Trigger();
my $reply = $trigger->processMessage($victim,$msg);
return $reply;
}
|
Atleast I think that is right. It seems to work anyway. Only just started with Perl so I imagine there is a better way.
Many Thanks,
TrUz |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Tue Sep 27, 2005 5:05 pm Post subject: |
|
|
| You don't want to be creating a new Trigger object every time the reply sub is called - that's inefficient. Instead, make the $trigger variable global. I hate saying global because I advise not using globals if you can. Ideally, the $trigger variable would be in your bot's class/object, then it is globally available but does not have the issues associated with global variables. Anyway, the main thing is to move "my $trigger = new Trigger();" somewhere outside of the reply sub. |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Tue Sep 27, 2005 5:51 pm Post subject: |
|
|
Cheers Mojave I have made the changes!
Can you explain to me what this means: \b.+\b
I have looked it up but I am still a little unsure. But I see it used in your diect responses. Is it just some kind of wildcard?
Cheers,
TrUz |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Tue Sep 27, 2005 7:34 pm Post subject: |
|
|
| TrUz wrote: | Can you explain to me what this means: \b.+\b
I have looked it up but I am still a little unsure. But I see it used in your diect responses. Is it just some kind of wildcard?
|
That's part of a regular expression. . means any character, + means 1 or more of the preceding thing, so .+ means one or more of any charater. \b means word boundary, so any whitespace or punctuation. Without actually looking back into my code, I guess I have it looking for words, although I don't know I why I wouldn't just use \w+, which is one or more word characters. I'd have to look at the code, but I'm lazy.  |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Tue Sep 27, 2005 7:38 pm Post subject: |
|
|
Cheers mate. Think I am getting my head round it now.
I was testing it using boo and book. It would never pick up book unless I done \bboo\b and \bbook\b.
Seems to work ok. I will keep at it though.
Thanks again.
TrUz |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Tue Sep 27, 2005 7:43 pm Post subject: |
|
|
| TrUz wrote: | Cheers mate. Think I am getting my head round it now.
I was testing it using boo and book. It would never pick up book unless I done \bboo\b and \bbook\b.
Seems to work ok. I will keep at it though.
Thanks again.
TrUz |
Ah, that wasn't in the module but in the response file. Shows you just how lazy I really am! haha
So right \bboo\b would not find book because of the trailing \b. It says look for a word boundary (whitespace, punctuation) and of course k is neither of those. |
|
| Back to top |
|
 |
TrUz Newbie

Joined: 24 Sep 2005 Posts: 14 Location: Peterborough, UK
 
|
Posted: Tue Sep 27, 2005 7:48 pm Post subject: |
|
|
Hehe, yeah sorry I forgot to meantion I was talking about the expressions in the response file.
I think I am getting there, I am chewing through the regular expressions on the Perl web site.
Good fun!
TrUz |
|
| Back to top |
|
 |
mbd5882 Newbie

Joined: 27 Jul 2006 Posts: 1
 
|
Posted: Sat Jul 29, 2006 12:47 pm Post subject: |
|
|
i dont see a download link
Same with every other topic in this forum |
|
| Back to top |
|
 |
patrick Newbie

Joined: 17 Apr 2006 Posts: 42 Location: Arnhem, the Netherlands
      votes: 1
|
Posted: Sat Jul 29, 2006 3:08 pm Post subject: |
|
|
use google.
because this forum changed from software the downloads where lost.
the download can be found here.
http://botwork.com/downloads.html |
|
| Back to top |
|
 |
zander God Like

Joined: 14 Jan 2004 Posts: 540 Location: england
 
|
Posted: Sun Jul 30, 2006 7:56 pm Post subject: |
|
|
mojaves website at botwork has it
[url]www.botwork.com [/url] |
|
| Back to top |
|
 |
|