Posted: Sat Oct 01, 2005 5:54 pm Post subject: Chatbot::Alpha 1.71
This is a small update to Chatbot::Alpha 1.7... or well, it's small in the code but can be quite big in the change.
I've reprogrammed the sorting method. I noticed in my bot that i am * would match before i am * years old, so you say "I am 15 years old" and it would reply "Are you really?"
So the new sorting method:
Whole triggers--those with NO wildcards--go first, of course. Then they're sorted in descending order with the number of whole words in them. I.E. wildcard triggers with 16 whole words go first, followed by those with 15 words, then 14, etc...
So i am * years old has 4 whole words, i am * only has 2, so the first trigger will be matched before the later one.
And so now this way, it is possible to have a trigger of just * because it will be sorted the very last. So you don't need to go through as much work with default_reply() and stuff, just make a * trigger.
Full Change Log
Code:
Version 1.71
- Redid sorting method. Sometimes triggers such as I AM * would match
before I AM * YEARS OLD.
Version 1.7
- Chatbot::Alpha::Syntax added.
- ^ command added.
- Module keeps filenames and line numbers internally, so on internal
errors such as 'Deep Recursion' and 'Infinite Loop' it can point you
to the source of the problem.
- $alpha->search() method added.
Version 1.61
- Chatbot::Alpha::Sort completed.
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.
Next Plans for Alpha
¤ Rename all methods (sortReplies, not sort_replies) etc.
¤ Add function for "that" kind of behavior:
Code:
// Idea of its format:
// "?" command to a trigger for a "that" value...
+ ask me a question
- Do you like lizards?{that=lizards}
+ yes
? lizards
- What's your favorite kind?
// So if they say "yes" immediately after
// being asked, it will ask "what's your
// favorite kind?" but anything else the user
// says will go elsewhere like normal.
¤ Better support for conditionals...
Code:
+ i am wearing a dress
% variable=sex
* male=>Guys shouldn't wear dresses...
* female=>What color is your dress?
* I don't know if you're a boy or a girl.
// Or for checking of a value...
+ is my name *
% value=<star1>
* {name}=>Yes, that's your name.
* No, your name is {name}! :-P
// Or doing multiple checks...
+ am i wearing a blue shirt
% value={shirt}/{color}
* yes/blue=>Yes, it's a blue shirt.
* yes/=>Your shirt isn't blue.
* no/blue=>You're wearing blue, but not as a shirt.
* no/=>You are not wearing a blue shirt.