]>
Commit | Line | Data |
---|---|---|
e628c597 MG |
1 | package POE::Component::IRC::Plugin::Logger::Irssi; |
2 | ||
440c5c51 | 3 | our $VERSION = 0.001001; |
e628c597 MG |
4 | |
5 | use 5.014000; | |
6 | use strict; | |
7 | use warnings; | |
8 | ||
9 | use parent qw/Exporter/; | |
10 | ||
11 | our @EXPORT_OK = qw/irssi_format/; | |
12 | ||
13 | ################################################## | |
14 | ||
15 | my %irssi_format = ( | |
16 | nick_change => sub { "-!- $_[0] is now known as $_[1]" }, | |
17 | topic_is => sub { "-!- Topic for $_[0]: $_[1]"}, | |
18 | topic_change => sub { | |
19 | my ($nick, $topic) = @_; | |
20 | return "-!- $nick changed the topic to: $topic" if $topic; | |
21 | return "-!- Topic unset by $nick" unless $topic; | |
22 | }, | |
23 | privmsg => sub{ "<$_[0]> $_[1]" }, | |
24 | notice => sub { "-$_[0]- $_[1]" }, | |
25 | action => sub { "* $_[0] $_[1]" }, | |
26 | join => sub { "-!- $_[0] [$_[1]] has joined $_[2]" }, | |
27 | part => sub { "-!- $_[0] [$_[1]] has left $_[2] [$_[3]]" }, | |
28 | quit => sub { "-!- $_[0] [$_[1]] has quit [$_[2]]"}, | |
29 | kick => sub { "-!- $_[1] was kicked from $_[2] by $_[0] [$_[3]]"}, | |
30 | topic_set_by => sub { "-!- Topic set by $_[1] [". localtime($_[2]) .']' }, | |
31 | ); | |
32 | ||
33 | for my $letter ('a' .. 'z', 'A' .. 'Z') { | |
34 | $irssi_format{"+$letter"} = sub { my $nick = shift; "-!- mode [+$letter @_] by $nick" }; | |
35 | $irssi_format{"-$letter"} = sub { my $nick = shift; "-!- mode [-$letter @_] by $nick" } | |
36 | } | |
37 | ||
38 | sub irssi_format { \%irssi_format } | |
39 | ||
40 | 1; | |
41 | __END__ | |
42 | ||
43 | =head1 NAME | |
44 | ||
45 | POE::Component::IRC::Plugin::Logger::Irssi - Log IRC events like irssi | |
46 | ||
47 | =head1 SYNOPSIS | |
48 | ||
49 | use POE::Component::IRC::Plugin::Logger::Irssi qw/irssi_format/; | |
50 | ... | |
51 | $irc->plugin_add(Logger => POE::Component::IRC::Plugin::Logger->new( | |
52 | Format => irssi_format, | |
53 | ... | |
54 | )); | |
55 | ||
56 | =head1 DESCRIPTION | |
57 | ||
58 | POE::Component::IRC::Plugin::Logger::Irssi is an extension to the L<POE::Component::IRC::Plugin::Logger> PoCo-IRC plugin that logs everything in a format similar to the one used by the irssi IRC client. | |
59 | ||
60 | It exports one function, B<irssi_format>, that returns a hashref to be used as the value to C<< POE::Component::IRC::Plugin::Logger->new >>'s C<format> argument. | |
61 | ||
62 | =head1 AUTHOR | |
63 | ||
64 | Marius Gavrilescu C<< <marius@ieval.ro> >> | |
65 | ||
66 | =head1 COPYRIGHT AND LICENSE | |
67 | ||
68 | Copyright (C) 2013 by Marius Gavrilescu | |
69 | ||
70 | This library is free software; you can redistribute it and/or modify | |
71 | it under the same terms as Perl itself, either Perl version 5.14.2 or, | |
72 | at your option, any later version of Perl 5 you may have available. | |
73 | ||
74 | ||
75 | =cut |