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