|
| Author |
Message |
mul Newbie

Joined: 08 Jul 2006 Posts: 3
 
|
Posted: Sat Jul 08, 2006 2:21 pm Post subject: hey everyone.. i need some help with mayabot |
|
|
Hey i dont know if this is the right forum but i need some help..
this is the example of what i want the bot to do:
if the person says "how are you mayabot?
and the bot answers"im fine thanks, and you?
the person:blablablah(whatever he says)
and the bot automaticly answers "ok blablabla"(specially on that answer that the person said right after the bots question.
sry for my "bad" english.
Thanks.
Mull |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sat Jul 08, 2006 3:12 pm Post subject: |
|
|
You would wanna store global variables (probably in a hashref) to remember the bot's last message to the user.
| Code: | # save the bots last reply
$lastreplies->{$user} = $reply;
...
if ($lastreplies->{$user} eq 'im fine thanks, and you?') {
$reply = "ok $msg";
} |
Or you can use RiveScript and just do this:
| Code: | + how are you*
- im fine thanks, and you?
+ *
% im fine thanks *
- ok <star> |
_________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
mul Newbie

Joined: 08 Jul 2006 Posts: 3
 
|
Posted: Sat Jul 08, 2006 3:34 pm Post subject: |
|
|
thaks!
where do i add the first code?
in the pl bot file? |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sat Jul 08, 2006 5:04 pm Post subject: |
|
|
Well first you'd need to declare the hashref, that would be in the main pl file:
| Code: | | our $lastreplies = {}; |
The "our" makes it global to all your subroutines and files you include later.
At the part where your bot's about to send a reply back to the human, put a copy of it into the hashref under the user's username:
| Code: | | $lastreplies->{$user} = $reply; |
Then, where your bot actually gets the replies, you can check the value of $lastreplies->{$user} and so your bot can carry on a conversation based on its previous response. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
mul Newbie

Joined: 08 Jul 2006 Posts: 3
 
|
Posted: Sun Jul 09, 2006 4:03 pm Post subject: |
|
|
hmm i tried to add it to my bot, but it didnt work:(
if anyone could add it for me and post it here, or send it on email(pm for mail adress) that would be very nice. |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sun Jul 09, 2006 4:39 pm Post subject: |
|
|
I can't give you a simple cut-and-paste example because I don't know how Mayabot works. The variables like $user and $reply may be named differently. If you learn Perl though and not just rely on cut-and-paste solutions, it would be very easy to figure out. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
|