Posted: Sat Aug 06, 2005 6:00 pm Post subject: Chatbot::Alpha 1.6
I haven't posted recent updates to Chatbot::Alpha here so here's the change log so far:
Quote:
Version 1.6
- Created Chatbot::Alpha::Sort for sorting your Alpha documents.
Version 1.5
- Added "stream" method, revised POD.
Version 1.4
- Fixed bug with wildcard subsitutitons.
Version 1.3
- Added the ">" and "<" commands, now used for topics.
Version 1.2
- "sort_replies" method added
Version 1.1
- Fixed a bug in reply matching with wildcards.
- Added a "#" command for executing System Commands.
Version 1.0
- Initial release.
If you don't know what Chatbot::Alpha is, it's a simplistic yet powerful response language used primarily for chatterbots.
Example of what an Alpha response document looks like:
Code:
// Test Replies
// A standard reply to "hello", with multiple responses.
+ hello
- Hello there!
- What's up?
- This is random, eh?
// A simple one-reply response to "what's up"
+ what's up
- Not much, you?
// A test using <star1>
+ say *
- Um.... "<star1>"
// This reply is referred to below.
+ identify yourself
- I am Alpha.
// Refers the asker back to the reply above.
+ who are you
@ identify yourself
// Conditionals Test
+ am i your master
* if master = 1::Yes, you are my master.
- No, you are not my master.
// Perl Evaluation Test
+ what is 2 plus 2
# $reply = "2 + 2 = 4";
// A Conversation Holder: Knock Knock!
+ knock knock
- Who's there?
& <msg> who?
& Ha! <msg>! That's a good one!
// A Conversation Holder: Rambling!
+ are you crazy
- I was crazy once.
& They locked me away...
& In a room with padded walls.
& There were rats there...
& Did I mention I was crazy once?
// Topic Test
+ you suck
- And you're very rude. Apologize now!{topic=apology}
> topic apology
+ *
- No, apologize for being so rude to me.
// Set {topic=random} to return to the default topic.
+ sorry
- See, that wasn't too hard. I'll forgive you.{topic=random}
< topic
Chatbot::Alpha::Sort
This is a new addition to the module that can be used to sort your existing Alpha documents into nicely alphabetized files.
For example, you can take your numerous Alpha files, run them through the sorting module, and you'd end up with files A.cba through Z.cba, star.cba for wildcarded replies, topics.cba for keeping topics together, and other.cba for anything else which starts a trigger (numbers, etc.)
And in each file the triggers are sorted alphabetically. For example in A.cba your triggers might be (in this order): "a", "a bot", "a boy", "about", "about *", "about half", etc... alphabetized.
So far Chatbot::Alpha::Sort only sorts in the method described, but in later versions it will be able to sort also by: keeping your original filename structure intact and just sorting replies within each file... and putting ALL replies into one single file.
Chatbot::Alpha::Sort now supports all three sorting methods:
Quote:
alpha - sorts into A.cba through Z.cba, etc.
intact - keeps original filenames intact, sorts replies within each file
single - merges all your replies into a single document
¤ ^ Command added--for continuation of long replies.
¤ Chatbot::Alpha::Syntax created for syntax checking
¤ Files/line numbers kept with each command*
¤ $alpha->search() method added
The ^ command is a new addition used for extending really long replies onto more lines. Example:
Code:
+ tell me a poem
- Little Miss Muffet,\n
^ sat on her tuffet,\n
^ in a nonchalant sort of way.\n\n
^ With her forcefield around her,\n
^ the spider, the bounder\n
^ is not in the picture today.
Chatbot::Alpha now keeps filenames and line numbers with each command it finds, so if an internal error arrises or you're searching for triggers, it can tell you which file and line it can be found on.
For example:
Code:
ERR: Deep Recursion (15+ loops in reply set) at ./replies/greetings.cba line 17
And the search() method can be used to search through your loaded replies and find all the triggers that match the string.
For example, searches for "one" and "sorry" in the testreplies.txt file:
Code:
For: one
+ one (topic: random) at ./testreplies.txt line 13
+ * (topic: apology) at ./testreplies.txt line 74
For: sorry
+ sorry (topic: random) at ./testreplies.txt line 26
+ sorry (topic: apology) at ./testreplies.txt line 78
+ * (topic: apology) at ./testreplies.txt line 74
And finally, Chatbot::Alpha::Syntax is now included for syntax checking of Alpha documents.
Hey I just got this going Cer, very nice. I like it.
Cannot seem to get the master thing working though.
Apart from that, all good.
TrUz
I haven't really cared much for support of conditionals... maybe later I'll add better conditional support, like...
Code:
+ i am wearing a dress
* condition:gender
% value:male=>Ew, guys shouldn't wear dresses.
% value:female=>What color is your dress?
% I don't know how weird that is since I don't know your gender.
Something like that seems a little more plausible.
When I tested that "* if master = 1" thing, it worked the first/only time I tested it. It might have to do with the value being a number.
You can always just use Perl.
Code:
+ am i your master
- No, you're not.
# if (&main::isMaster($id)) {
# $reply = "Yes you are my master.";
# }
A little messy but it works. _________________ Current Site (2008) http://www.cuvou.com/