User Control Panel
Advertisements

HELP US, HELP YOU!

Trigger - a direct response chat module

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add-ons
View unanswered posts
Author Message
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Thu Jan 15, 2004 9:09 pm    Post subject: Reply with quote

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
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Mon Sep 26, 2005 5:20 pm    Post subject: Reply with quote

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
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Tue Sep 27, 2005 8:22 am    Post subject: Reply with quote

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
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Tue Sep 27, 2005 9:51 am    Post subject: Reply with quote

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. Smile

TrUz
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Sep 27, 2005 11:53 am    Post subject: Reply with quote

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. Smile

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
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Tue Sep 27, 2005 1:53 pm    Post subject: Reply with quote

Cheers Cer, found it now. I will give it a bash now I know how White Warrior is doing it. Smile

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. Smile Only just started with Perl so I imagine there is a better way.

Many Thanks,

TrUz
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Tue Sep 27, 2005 5:05 pm    Post subject: Reply with quote

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
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Tue Sep 27, 2005 5:51 pm    Post subject: Reply with quote

Cheers Mojave I have made the changes! Smile

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
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Tue Sep 27, 2005 7:34 pm    Post subject: Reply with quote

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. Wink
Back to top
TrUz
Newbie
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Tue Sep 27, 2005 7:38 pm    Post subject: Reply with quote

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. Smile

Thanks again.

TrUz
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Tue Sep 27, 2005 7:43 pm    Post subject: Reply with quote

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. Smile

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
Newbie


Joined: 24 Sep 2005
Posts: 14
Location: Peterborough, UK
Reputation: 13.6

PostPosted: Tue Sep 27, 2005 7:48 pm    Post subject: Reply with quote

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! Smile

TrUz
Back to top
mbd5882
Newbie
Newbie


Joined: 27 Jul 2006
Posts: 1


PostPosted: Sat Jul 29, 2006 12:47 pm    Post subject: Reply with quote

i dont see a download link
Question
Same with every other topic in this forum
Back to top
patrick
Newbie
Newbie


Joined: 17 Apr 2006
Posts: 42
Location: Arnhem, the Netherlands
Reputation: 5.3Reputation: 5.3Reputation: 5.3Reputation: 5.3Reputation: 5.3
votes: 1

PostPosted: Sat Jul 29, 2006 3:08 pm    Post subject: Reply with quote

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
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Sun Jul 30, 2006 7:56 pm    Post subject: Reply with quote

mojaves website at botwork has it

[url]www.botwork.com [/url]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add-ons All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group