| 1 | package POE::Component::IRC::Plugin::Hello; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.014000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Encode qw/encode decode/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Unicode::Normalize qw/NFC/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = '0.001003'; | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use List::Util qw/first/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use IRC::Utils qw/parse_user/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use POE::Component::IRC::Plugin qw/PCI_EAT_NONE/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | sub new { | ||||||||||
| 18 | 2 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 19 | 2 | my $self = { | |||||||||
| 20 | greetings => [ | ||||||||||
| 21 | qw/privet hello salut salutari neata neaţa neața neatza | ||||||||||
| 22 | hola hey hi bonjour wassup sup hallo chikmaa | ||||||||||
| 23 | tungjatjeta parev salam namaskaar mingalarba ahoy | ||||||||||
| 24 | saluton allo moin aloha namaste shalom ciào ciao servus | ||||||||||
| 25 | salve ave merhaba witaj hei hola selam sawubona | ||||||||||
| 26 | geodemorgen hoi καλημέρα/, | ||||||||||
| 27 | 'what\'s up', 'que tal', 'こんにちは', '你好', 'ni hao', | ||||||||||
| 28 | 'добро јутро', 'γεια σας', 'bom dia', 'hyvää huomenta'], | ||||||||||
| 29 | @_ | ||||||||||
| 30 | }; | ||||||||||
| 31 | |||||||||||
| 32 | 2 | bless $self, $class | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub PCI_register { | ||||||||||
| 36 | 0 | ▶ | my ($self, $irc) = @_; | ||||||||
|
Subroutine
PCI_register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 37 | 0 | $irc->plugin_register($self, SERVER => qw/public/); | |||||||||
| 38 | 0 | 1 | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub PCI_unregister { 1 } | ||||||||
|
Subroutine
PCI_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 42 | |||||||||||
| 43 | sub S_public{ | ||||||||||
| 44 | 18 | ▶ | my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_; | ||||||||
|
Subroutine
S_public: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 18 | my $nick = parse_user $$rfullname; | |||||||||
| 46 | 18 | my $mynick = $irc->nick_name; | |||||||||
| 47 | 18 | my $message = NFC decode 'UTF-8', $$rmessage; | |||||||||
| 48 | 18 | my @hello = @{$self->{greetings}}; | |||||||||
| 49 | |||||||||||
| 50 | 18 | ▶ | my $match = first { $message =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/is } @hello; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 18 | my $randhello = encode 'UTF-8', $hello[int rand $#hello]; | |||||||||
| 52 | 18 | ▶ | $irc->yield(privmsg => $$rchannels->[0] => "$randhello, $nick") if $match; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 18 | PCI_EAT_NONE | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | __END__ | ||||||||||