|
| Author |
Message |
Teario Member

Joined: 25 Jun 2004 Posts: 130 Location: Liverpool(home) or Derby(uni), UK
  votes: 3
|
Posted: Sat Jul 01, 2006 6:27 pm Post subject: preventing undefined? |
|
|
It took me a little while to figure out how to use this, but once I did I was glad. I am using your Aiden brain and some of the responses make me laugh so much, especially when he asks if crabs think humans walk sideways.
I decided to have a try at making my own brain, but before I do I just wanted to ask if there is a way to prevent things like this happening:
| Quote: | [Teario][ says (19:22):
hey
[Crybot] says (19:22):
Hello undefined! |
Can you make it so if there is no name defined, he will just say "Hello"?
Thanks  |
|
| Back to top |
|
 |
darkmonkey The Merovingian

Joined: 18 Apr 2004 Posts: 2557 Location: London, England
     votes: 7
|
Posted: Sat Jul 01, 2006 8:45 pm Post subject: |
|
|
Sure. Other than just editing the brain, you could just change "undefined" to "" (nothing) before the message is sent:
| Code: | my $message = $brain->getReply($user, $msg); # or whatever
$message =~ s/undefined//isg;
$self->sendMessage($message); |
_________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ] |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sat Jul 01, 2006 9:07 pm Post subject: |
|
|
"undefined" is used for any <get> tag that uses a variable that was never <set> for the current user. So if the user tells the bot their name before the bot tries to repeat it, it'll be fine. My bot handled this with an introduction interview for all new users where it'd ask them questions like this. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
patrick Newbie

Joined: 17 Apr 2006 Posts: 42 Location: Arnhem, the Netherlands
      votes: 1
|
Posted: Sat Jul 01, 2006 9:13 pm Post subject: |
|
|
| Code: | + hey
* name = * => Hey, <get name>
- hey. |
I don't know if this works. can't test this because someone else is using msn. |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sun Jul 02, 2006 3:21 am Post subject: |
|
|
That wouldn't work, it would check if "name" equals "*"
I did build in something to do exactly what you're wanting though--seeing if "name" is defined. The inequality symbol is a question mark (with no "value")... e.g.
| Code: | + hey
* name ? => Hey, <get name>
- hey. |
http://search.cpan.org/perldoc?RiveScript
| Quote: | You can perform the following operations on variable checks:
| Code: | = equal to
!= not equal to
< less than
<= less than or equal to
> greater than
>= greater than or equal to
? returns true if the var is even defined |
|
_________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
Teario Member

Joined: 25 Jun 2004 Posts: 130 Location: Liverpool(home) or Derby(uni), UK
  votes: 3
|
Posted: Sun Jul 02, 2006 10:42 am Post subject: |
|
|
Okay, I think ive got the hang of it now
Thanks for your help |
|
| Back to top |
|
 |
|