User Control Panel
Advertisements

HELP US, HELP YOU!

Chatbot::Alpha

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


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

PostPosted: Fri Nov 12, 2004 12:26 am    Post subject: Reply with quote

Here's the 1.0 release of Chatbot::Alpha.

For module information, check http://www.aichaos.com/docs/alpha.html - there you'll find how to use the module, and a simple tutorial on how to program Alpha replies.

Here's the test reply file, if you want to see what it looks like:
Code:
// Test Replies<br /><br />// A standard reply to "hello", with multiple responses.<br />+ hello<br />- Hello there!<br />- What's up?<br />- This is random, eh?<br /><br />// A simple one-reply response to "what's up"<br />+ what's up<br />- Not much, you?<br /><br />// A test using <star1><br />+ say *<br />- Um.... "<star1>"<br /><br />// This reply is referred to below.<br />+ identify yourself<br />- I am Alpha.<br /><br />// Refers the asker back to the reply above.<br />+ who are you<br />@ identify yourself<br /><br />// Conditionals Test<br />+ am i your master<br />* if master = 1::Yes, you are my master.<br />- No, you are not my master.<br /><br />// A Conversation Holder: Knock Knock!<br />+ knock knock<br />- Who's there?<br />& <msg> who?<br />& Ha! <msg>! That's a good one!<br /><br />// A Conversation Holder: Rambling!<br />+ are you crazy<br />- I was crazy once.<br />& They locked me away...<br />& In a room with padded walls.<br />& There were rats there...<br />& Did I mention I was crazy once?


It's a simple line-by-line command-driven language. The first character on each line is the command (the list of commands can be found on the module's POD, as stated above).

When getting a reply, you send $id and $msg -- $id would (in most cases) be your user's username; it's used to keep track of conversation (for example, that "knock knock" reply, it needs to keep track of the user to know to go back to that reply next time).

And a quick overview of the synopsis:

Code:
use Chatbot::Alpha;<br /><br />my $alpha = new Chatbot::Alpha (debug => 1);<br /><br />$alpha->load_folder ('./replies');<br />$alpha->load_file ('./more_replies.txt');<br /><br /># Set and remove variables.<br />$alpha->set_variable ("master", "1");<br />$alpha->remove_variable ("master");<br />$alpha->set_variable ("var", "value");<br />$alpha->clear_variables;<br /><br /># Go get a reply.<br />my $user = "foo";<br />my $message = "Hello Alpha";<br />my $reply = $alpha->reply ($user,$message);


So tell me what you think. Post any questions, comments, bugs, compliments, etc. in reply here. Smile

Also: This module has been tested quite thoroughly, although I have not tested what happens if you use the commands in other ways (for example, if you have a command sequence of "+ - & -", I don't know what would happen)... so if you want to test out different combinations and report back with their results (if they broke it, or how it turned out if it did work)... that would be nice too. Smile

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Fri Nov 12, 2004 7:32 am    Post subject: Reply with quote

Great, thanks..........................
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Fri Nov 12, 2004 8:30 am    Post subject: Reply with quote

Yes, great work Cer. B)
Back to top
Gavin
God Like
God Like


Joined: 15 Mar 2004
Posts: 661
Location: Manchester, UK
Reputation: 36.2Reputation: 36.2Reputation: 36.2Reputation: 36.2

PostPosted: Fri Nov 12, 2004 4:23 pm    Post subject: Reply with quote

Thats cool I might use this....
+1

_________________
MSN: gavin [at] gavinbrittain [dot] co [dot] uk
E-Portfolio: www.gavinbrittain.co.uk (New version comming soon)
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Fri Nov 12, 2004 10:22 pm    Post subject: Reply with quote

Its really easy.

Add this to your commands

Quote:
if (exists $self->{alpha}){

if (lc($msg) =~ /^!exit$/){

delete $self->{alpha};
         delete $self->{room};
         $self->sendmsg("-info- You have now exited Alpha mode.");

} else {
         my $alpha = new Chatbot::Alpha (debug => 0);
my $load = $alpha->load_file ('./testreplies.txt');
die "Error: $load" unless $load == 1;
my $id = $username;
chomp $msg;
$alpha->set_variable ("username", $username);
my $reply = $alpha->reply ($username,$msg);
$alpha->remove_variable ("username");
$self->sendmsg("$reply", Name => "[ Alpha ] - [ Type !exit to leave Alpha Mode ]");
}

elsif ($msg =~ /^!alpha$/){
$self->{room} = 1;
$self->{alpha} = 1;
$self->sendmsg("You are now chatting to Alpha.\n\nYou can pick up the module at: http://aichaos.com");

}


Smile
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Fri Nov 12, 2004 10:28 pm    Post subject: Reply with quote

uh, I think you mixed that up a bit. Razz
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Fri Nov 12, 2004 10:35 pm    Post subject: Reply with quote

@Mojave: Me? Where? What's wrong with it!? lol. Smile
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sat Nov 13, 2004 12:20 am    Post subject: Reply with quote

ok, maybe I'm the one that's mixed up. Razz You're logic didn't seem right. In any case, you create a new $alpha object every single time a message comes in, right? That's not good.
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Sat Nov 13, 2004 12:35 am    Post subject: Reply with quote

Oh you're right, but I'm not sure how to change that. Sad
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Sat Nov 13, 2004 1:00 pm    Post subject: Reply with quote

Just put the new bit in...either where you start it up or sub connected or something....Something thats only processed once.
Back to top
purcelly
God Like
God Like


Joined: 10 Jun 2004
Posts: 560
Location: North West, England
Reputation: 35.1Reputation: 35.1Reputation: 35.1Reputation: 35.1

PostPosted: Sat Nov 13, 2004 3:02 pm    Post subject: Reply with quote

nice cer!

and nice command TCS helped me alot although i was a bit confused at first

i am alright now it works Very Happy
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Sat Nov 13, 2004 4:21 pm    Post subject: Reply with quote

Smile I love helping!

Thanks Cer. B)
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Sat Nov 13, 2004 7:48 pm    Post subject: Reply with quote

After many many hours of being lazy, I've created the files to put the Alpha brain into Juggernaut.

If your Juggernaut has a "brains" folder, this should be compatible (I forget what version started doing that Razz ).

Zip attached, extract the two files (alpha_load.pl and alpha_get.pl) into your "brains" folder. And to make your bot use them, change your bot's "Brain:" and "Reply" fields to:

Quote:
Brain: Alpha
Reply: ./replies/alpha


The reply folder can be whereever you want to put your Alpha replies into. All reply files should be a .TXT, or you can edit alpha_load.pl to change that.

The Codes:

Code:
sub alpha_load {<br />     # Incoming data for the brain.<br />     my ($bot,$brain,$dir) = @_;<br /><br />     use Chatbot::Alpha;<br /><br />     # Get the Alpha brain going.<br />     $chaos->{$bot}->{_alpha} = new Chatbot::Alpha (<br />          debug => 0,<br />     );<br /><br />     # Load the directory.<br />     $chaos->{$bot}->{_alpha}->load_folder ($dir, "txt");<br /><br />     # All done!<br />     return 1;<br />}


Code:
sub alpha_get {<br />     # Incoming data for the brain.<br />     my ($brain,$self,$client,$listener,$msg,$omsg,$sn) = @_;<br /><br />     $brain = lc($brain);<br />     $brain =~ s/ //g;<br /><br />     $sn = lc($sn);<br />     $sn =~ s/ //g;<br /><br />     # Input all kinds of variables.<br />     foreach my $var (keys %{$chaos->{_users}->{$client}}) {<br />          $chaos->{$sn}->{_alpha}->set_variable ($var, $chaos->{_users}->{$client}->{$var});<br />     }<br /><br />     my $reply = $chaos->{$sn}->{_alpha}->reply ($client,$msg);<br /><br />     # Clear variables.<br />     $chaos->{$sn}->{_alpha}->clear_variables;<br /><br />     return $reply;<br />}


It sends all user variables (name, age, etc.) into the Alpha brain. If you want it to send more (i.e. username, isAdmin, isMaster, etc.) you can put in the codes to do that yourself.

Attached.

_________________
Current Site (2008) http://www.cuvou.com/
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