From 28c9644158dd3410d243b2567f216c75cf7a6a1a Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 7 Jun 2014 23:27:17 +0300 Subject: [PATCH] Allow ! or . after a greeting --- lib/POE/Component/IRC/Plugin/Hello.pm | 2 +- t/POE-Component-IRC-Plugin-Hello.t | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/POE/Component/IRC/Plugin/Hello.pm b/lib/POE/Component/IRC/Plugin/Hello.pm index a5770aa..f6bc02b 100644 --- a/lib/POE/Component/IRC/Plugin/Hello.pm +++ b/lib/POE/Component/IRC/Plugin/Hello.pm @@ -34,7 +34,7 @@ sub S_public{ my $mynick = $irc->nick_name; my @hello = @{$self->{greetings}}; - my $match = first { $$rmessage =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*$/i } @hello; + my $match = first { $$rmessage =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/i } @hello; $irc->yield(privmsg => $$rchannels->[0] => $hello[int rand $#hello].", $nick") if $match; PCI_EAT_NONE } diff --git a/t/POE-Component-IRC-Plugin-Hello.t b/t/POE-Component-IRC-Plugin-Hello.t index 7eae8c8..526f0bf 100644 --- a/t/POE-Component-IRC-Plugin-Hello.t +++ b/t/POE-Component-IRC-Plugin-Hello.t @@ -3,7 +3,7 @@ use v5.14; use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 18; use Test::MockObject; BEGIN { use_ok('POE::Component::IRC::Plugin::Hello') }; @@ -28,6 +28,8 @@ runtest 'PrIvEt', 1, 'privet in mixed case'; runtest ' privet ', 1, 'privet with spaces'; runtest 'hellobot: privet', 1, 'addressed privet'; runtest 'hellobot: privet ', 1, 'addressed privet with spaces'; +runtest 'privet!', 1, 'privet with exclamation mark'; +runtest 'privet.', 1, 'privet with full stop'; runtest 'ahoy', 1, 'ahoy'; runtest 'namaste', 1, 'namaste'; runtest 'neaţa', 1, 'neaţa (UTF-8 test)'; @@ -36,8 +38,8 @@ runtest 'こんにちは', 1, 'こんにちは (another UTF-8 test)'; runtest 'salu', 0, 'salu (misspelling)'; runtest 'hii', 0, 'hii (misspelling)'; runtest 'neaţa mgv', 0, 'neaţa mgv (valid greeting with garbage after it)'; +runtest 'hi,', 0, 'hi, (bad punctuation)'; $self = POE::Component::IRC::Plugin::Hello->new(greetings => ['sayonara']); - runtest 'privet', 0, 'custom greetings - privet'; runtest ' sayonara ', 1, 'custom greetings - sayonara'; -- 2.39.2