1 package POE
::Component
::IRC
::Plugin
::Hello
;
7 use Encode qw
/encode decode/;
8 use Unicode
::Normalize qw
/NFC/;
10 our $VERSION = '0.001002';
12 use List
::Util qw
/first/;
14 use IRC
::Utils qw
/parse_user/;
15 use POE
::Component
::IRC
::Plugin qw
/PCI_EAT_NONE/;
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'],
36 my ($self, $irc) = @_;
37 $irc->plugin_register($self, SERVER
=> qw
/public/);
41 sub PCI_unregister
{ 1 }
44 my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_;
45 my $nick = parse_user
$$rfullname;
46 my $mynick = $irc->nick_name;
47 my $message = NFC decode
'UTF-8', $$rmessage;
48 my @hello = @
{$self->{greetings
}};
50 my $match = first
{ $message =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/i } @hello;
51 my $randhello = encode
'UTF-8', $hello[int rand $#hello];
52 $irc->yield(privmsg
=> $$rchannels->[0] => "$randhello, $nick") if $match;
61 POE::Component::IRC::Plugin::Hello - PoCo-IRC plugin that says hello
65 use POE::Component::IRC::Plugin::Hello;
67 my $irc = POE::Component::IRC::State->spawn(...);
68 $irc->plugin_add(Hello => POE::Component::IRC::Plugin::Hello->new);
72 POE::Component::IRC::Plugin::Hello is a PoCo-IRC plugin that greets back
73 who greet him or a channel in public. It knows how to say hello in several
74 languages, and greets people in a randomly chosen language.
76 The list of greetings is configurable by the plugin user.
80 L<POE::Component::IRC::Plugin>
84 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
86 =head1 COPYRIGHT AND LICENSE
88 Copyright (C) 2013 by Marius Gavrilescu
90 This library is free software; you can redistribute it and/or modify
91 it under the same terms as Perl itself, either Perl version 5.14.2 or,
92 at your option, any later version of Perl 5 you may have available.