From: Marius Gavrilescu Date: Thu, 29 Jan 2015 07:50:47 +0000 (+0200) Subject: Work internally with UTF-8 X-Git-Tag: 0.001003~4 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=128b9459a22314c185c5ad188693352c616699ef;p=poe-component-irc-plugin-hello.git Work internally with UTF-8 --- diff --git a/lib/POE/Component/IRC/Plugin/Hello.pm b/lib/POE/Component/IRC/Plugin/Hello.pm index eb83848..aa33806 100644 --- a/lib/POE/Component/IRC/Plugin/Hello.pm +++ b/lib/POE/Component/IRC/Plugin/Hello.pm @@ -3,6 +3,9 @@ package POE::Component::IRC::Plugin::Hello; use 5.014000; use strict; use warnings; +use utf8; +use Encode qw/encode decode/; + our $VERSION = '0.001002'; use List::Util qw/first/; @@ -38,10 +41,12 @@ sub S_public{ my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_; my $nick = parse_user $$rfullname; my $mynick = $irc->nick_name; + my $message = decode 'UTF-8', $$rmessage; my @hello = @{$self->{greetings}}; - my $match = first { $$rmessage =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/i } @hello; - $irc->yield(privmsg => $$rchannels->[0] => $hello[int rand $#hello].", $nick") if $match; + my $match = first { $message =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/i } @hello; + my $randhello = encode 'UTF-8', $hello[int rand $#hello]; + $irc->yield(privmsg => $$rchannels->[0] => "$randhello, $nick") if $match; PCI_EAT_NONE }