Skip Menu |

This queue is for tickets about the Bot-BasicBot-Pluggable CPAN distribution.

Report information
The Basics
Id: 39389
Status: resolved
Priority: 0/
Queue: Bot-BasicBot-Pluggable

People
Owner: MDOM [...] cpan.org
Requestors: grum [...] grum.nl
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.50
Fixed in: (no value)



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;
From: grum [...] grum.nl
Right, I completely overlooked the fact it could also accept @factiods like ('|a','a','a|b'). It should handle them correctly now making infobot<->infobot working again. This means that the following 2 lines are completely the same: foo is a|b|c|d|e foo is |a or |b or |c or |d or |e
--- 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 17:20:30 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,13 @@ # add these factoids to the list, trimming trailing space after | for (@factoids) { - my $alt = s/^\|\s*// ? 1 : 0; + my @alternates = split /\s*\|\s*/; + my $alternate = scalar @alternates > 1 ? 1 : 0; + push @current, { - alternate => $alt, + alternate => $alternate, text => $_, - }; + } for grep length, @alternates; } 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;
Hello! Show quoted text
> Right, I completely overlooked the fact it could also accept @factiods > like ('|a','a','a|b'). It should handle them correctly now making > infobot<->infobot working again. > > This means that the following 2 lines are completely the same: > foo is a|b|c|d|e > foo is |a or |b or |c or |d or |e
Thanks for the patched, but it seems that this problem was already solved between 0.50 and 0.60. At least with my bot both cases are exactly the same. But maybe you can test it yourself with an uptodate copy? Best wishes, Mario