X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPOE%2FComponent%2FIRC%2FPlugin%2FHello.pm;h=75e2f5b3829bc0a43581451c4233600e2b0fc764;hb=a5a095f29b8675080c2252b7a15792dab7d820d0;hp=eb83848eebcdce6b60367b1605f6292c002fc43d;hpb=7ca2bb7c344615d1aa54c5f00e3922a406af3634;p=poe-component-irc-plugin-hello.git diff --git a/lib/POE/Component/IRC/Plugin/Hello.pm b/lib/POE/Component/IRC/Plugin/Hello.pm index eb83848..75e2f5b 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/; @@ -18,8 +21,10 @@ sub new { hola hey hi bonjour wassup sup hallo chikmaa tungjatjeta parev salam namaskaar mingalarba ahoy saluton allo moin aloha namaste shalom ciào ciao servus - salve ave merhaba witaj hei hola selam sawubona/, - "what's up", 'que tal', 'こんにちは', '你好', 'ni hao'], + salve ave merhaba witaj hei hola selam sawubona + geodemorgen hoi καλημέρα/, + "what's up", 'que tal', 'こんにちは', '你好', 'ni hao', + 'добро јутро', 'γεια σας', 'bom dia', 'hyvää huomenta'], @_ }; @@ -38,10 +43,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 }