User Control Panel
Advertisements

HELP US, HELP YOU!

preventing undefined?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> RiveScript
View unanswered posts
Author Message
Teario
Member
Member


Joined: 25 Jun 2004
Posts: 130
Location: Liverpool(home) or Derby(uni), UK
Reputation: 59.8
votes: 3

PostPosted: Sat Jul 01, 2006 6:27 pm    Post subject: preventing undefined? Reply with quote

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 Smile
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Sat Jul 01, 2006 8:45 pm    Post subject: Reply with quote

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
Upgraded Agent


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

PostPosted: Sat Jul 01, 2006 9:07 pm    Post subject: Reply with quote

"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. Wink 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
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 01, 2006 9:13 pm    Post subject: Reply with quote

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
Upgraded Agent


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

PostPosted: Sun Jul 02, 2006 3:21 am    Post subject: Reply with quote

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
Member


Joined: 25 Jun 2004
Posts: 130
Location: Liverpool(home) or Derby(uni), UK
Reputation: 59.8
votes: 3

PostPosted: Sun Jul 02, 2006 10:42 am    Post subject: Reply with quote

Okay, I think ive got the hang of it now Smile

Thanks for your help
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> RiveScript 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