Subject: | Patch for alternatives behaviour |
The attached patch makes the Infobot work as described in the sourcecode
and pod.
It will allow you to properly use alternations with '|' (pipe), along
side with 'or' and 'also'.
Also it loosens up the strictness around the '?', it will now allow
whitespace before it without 'tainting' the fact it searches for.
(before it would search for the fact with the whitespace attached and
thus find nothing)
Subject: | Bot-BasicBot-Pluggable-0.50_01.patch |
--- Bot-BasicBot-Pluggable-0.50/lib/Bot/BasicBot/Pluggable/Module/Infobot.pm Sat Mar 19 17:38:25 2005
+++ Bot-BasicBot-Pluggable-0.50/lib/Bot/BasicBot/Pluggable/Module/Infobot.pm Thu Sep 18 16:00:39 2008
@@ -150,7 +150,7 @@
# fallback - passively learn things and answer questions.
- if ( $body =~ s/\?+$// and ( $mess->{address} or $self->get("user_passive_ask") ) ) {
+ if ( $body =~ s/\s*\?+$// and ( $mess->{address} or $self->get("user_passive_ask") ) ) {
# literal question?
my $literal = 1 if ($body =~ s/^literal\s+//i);
@@ -308,11 +308,15 @@
# add these factoids to the list, trimming trailing space after |
for (@factoids) {
- my $alt = s/^\|\s*// ? 1 : 0;
push @current, {
- alternate => $alt,
+ alternate => 0,
text => $_,
- };
+ } and next unless m/\|/;
+
+ push @current, {
+ alternate => 1,
+ text => $_,
+ } for split /\s*\|\s*/;
}
my $set = {
--- Bot-BasicBot-Pluggable-0.50/lib/Bot/BasicBot/Pluggable.pm Sat Mar 19 17:38:25 2005
+++ Bot-BasicBot-Pluggable-0.50/lib/Bot/BasicBot/Pluggable.pm Thu Sep 18 16:01:40 2008
@@ -121,7 +121,7 @@
use strict;
use warnings;
-our $VERSION = '0.50';
+our $VERSION = '0.50_01';
use POE;
use Bot::BasicBot;