From: Marius Gavrilescu Date: Sat, 14 Nov 2015 18:43:24 +0000 (+0000) Subject: Respond to !forget, even if unaddressed X-Git-Tag: 0.001003~2 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=6849c08013b55e9a18f036768da28fec1a737101;p=poe-component-irc-plugin-infobot.git Respond to !forget, even if unaddressed --- diff --git a/lib/POE/Component/IRC/Plugin/Infobot.pm b/lib/POE/Component/IRC/Plugin/Infobot.pm index bd8d83d..c2969b6 100644 --- a/lib/POE/Component/IRC/Plugin/Infobot.pm +++ b/lib/POE/Component/IRC/Plugin/Infobot.pm @@ -86,8 +86,8 @@ sub runcmd{ infobot_add $self, $irc, $1, $2, $to, $nick if $addressed } elsif (/^(.+)\?$/) { infobot_query $self, $irc, $1, $to, $nick, $addressed - } elsif (/^forget\s+(.*)$/) { - infobot_forget $self, $irc, $1, $to, $nick if $addressed + } elsif ($addressed && /^!?forget\s+(.*)$/ || /^!forget\s+(.*)$/) { + infobot_forget $self, $irc, $1, $to, $nick } } diff --git a/t/POE-Component-IRC-Plugin-Infobot.t b/t/POE-Component-IRC-Plugin-Infobot.t index cbe422e..8846b83 100644 --- a/t/POE-Component-IRC-Plugin-Infobot.t +++ b/t/POE-Component-IRC-Plugin-Infobot.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::MockObject; -use Test::More tests => 16; +use Test::More tests => 17; BEGIN { use_ok('POE::Component::IRC::Plugin::Infobot') }; @@ -42,6 +42,7 @@ runtest 'bot: a is c', '... but a is b!', 'redefine factoid'; runtest 'a?', 'a is b', 'query'; runtest 'bot: forget a', 'mgv: I forgot a', 'forget'; runtest 'bot: forget a', 'I didn\'t have anything matching a, mgv', 'forget inexistent factoid'; +runtest '!forget a', 'I didn\'t have anything matching a, mgv', '!forget'; runtest 'a?', undef, 'query for inexistent factoid'; runtest 'bot: a?', 'I don\'t know, mgv', 'addressed query for inexistent factoid';