X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPOE%2FComponent%2FIRC%2FPlugin%2FHello.pm;h=eb83848eebcdce6b60367b1605f6292c002fc43d;hb=7ca2bb7c344615d1aa54c5f00e3922a406af3634;hp=1820f841773566d67faee8abba35797e5d62bf02;hpb=29280d6c20a4abbb4a2f2efc421e21c88b3cb9ca;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 1820f84..eb83848 100644 --- a/lib/POE/Component/IRC/Plugin/Hello.pm +++ b/lib/POE/Component/IRC/Plugin/Hello.pm @@ -1,8 +1,9 @@ -package POE::Component::IRC::Plugin::Hello 0.001; +package POE::Component::IRC::Plugin::Hello; use 5.014000; use strict; use warnings; +our $VERSION = '0.001002'; use List::Util qw/first/; @@ -10,32 +11,38 @@ use IRC::Utils qw/parse_user/; use POE::Component::IRC::Plugin qw/PCI_EAT_NONE/; sub new { - my $class = shift; - my $self = { - greetings => [qw/privet hello salut salutari neata neaţa hola hey hi bonjour niihau 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', 'こんにちは', '你好'], - @_ - }; - - bless $self, $class + my $class = shift; + my $self = { + greetings => [ + qw/privet hello salut salutari neata neaţa neața neatza + 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'], + @_ + }; + + bless $self, $class } sub PCI_register { - my ($self, $irc) = @_; - $irc->plugin_register($self, SERVER => qw/public/); - 1 + my ($self, $irc) = @_; + $irc->plugin_register($self, SERVER => qw/public/); + 1 } sub PCI_unregister { 1 } sub S_public{ - my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_; - my $nick = parse_user $$rfullname; - my $mynick = $irc->nick_name; - my @hello = @{$self->{greetings}}; - - my $match = first { $$rmessage =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*$/i } @hello; - $irc->yield(privmsg => $$rchannels->[0] => $hello[int rand $#hello].", $nick") if $match; - PCI_EAT_NONE + my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_; + my $nick = parse_user $$rfullname; + my $mynick = $irc->nick_name; + 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; + PCI_EAT_NONE } 1;