X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPOE%2FComponent%2FIRC%2FPlugin%2FHello.pm;h=f6bc02bfda1d7f9e1e98d305693538c610df2564;hb=28c9644158dd3410d243b2567f216c75cf7a6a1a;hp=90c14f1223cc5844294d8cedb6466827717e4b54;hpb=d4df44503d8844b01f39da9dae5c546623d3a99f;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 90c14f1..f6bc02b 100644 --- a/lib/POE/Component/IRC/Plugin/Hello.pm +++ b/lib/POE/Component/IRC/Plugin/Hello.pm @@ -11,32 +11,32 @@ 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 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'], - @_ - }; + my $class = shift; + my $self = { + greetings => [qw/privet hello salut salutari neata neaţa 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 + 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;