Replace "niihau" with "ni hao"
[poe-component-irc-plugin-hello.git] / lib / POE / Component / IRC / Plugin / Hello.pm
CommitLineData
29280d6c
MG
1package POE::Component::IRC::Plugin::Hello 0.001;
2
3use 5.014000;
4use strict;
5use warnings;
6
7use List::Util qw/first/;
8
9use IRC::Utils qw/parse_user/;
10use POE::Component::IRC::Plugin qw/PCI_EAT_NONE/;
11
12sub new {
13 my $class = shift;
14 my $self = {
8ff57ebf 15 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'],
29280d6c
MG
16 @_
17 };
18
19 bless $self, $class
20}
21
22sub PCI_register {
23 my ($self, $irc) = @_;
24 $irc->plugin_register($self, SERVER => qw/public/);
25 1
26}
27
28sub PCI_unregister { 1 }
29
30sub S_public{
31 my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_;
32 my $nick = parse_user $$rfullname;
33 my $mynick = $irc->nick_name;
34 my @hello = @{$self->{greetings}};
35
36 my $match = first { $$rmessage =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*$/i } @hello;
37 $irc->yield(privmsg => $$rchannels->[0] => $hello[int rand $#hello].", $nick") if $match;
38 PCI_EAT_NONE
39}
40
411;
42__END__
43
44=head1 NAME
45
46POE::Component::IRC::Plugin::Hello - PoCo-IRC plugin that says hello
47
48=head1 SYNOPSIS
49
50 use POE::Component::IRC::Plugin::Hello;
51
52 my $irc = POE::Component::IRC::State->spawn(...);
53 $irc->plugin_add(Hello => POE::Component::IRC::Plugin::Hello->new);
54
55=head1 DESCRIPTION
56
57POE::Component::IRC::Plugin::Hello is a PoCo-IRC plugin that greets back
58who greet him or a channel in public. It knows how to say hello in several
59languages, and greets people in a randomly chosen language.
60
61The list of greetings is configurable by the plugin user.
62
63=head1 SEE ALSO
64
65L<POE::Component::IRC::Plugin>
66
67=head1 AUTHOR
68
69Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
70
71=head1 COPYRIGHT AND LICENSE
72
73Copyright (C) 2013 by Marius Gavrilescu
74
75This library is free software; you can redistribute it and/or modify
76it under the same terms as Perl itself, either Perl version 5.14.2 or,
77at your option, any later version of Perl 5 you may have available.
78
79
80=cut
This page took 0.014725 seconds and 4 git commands to generate.