File Coverage

blib/lib/Bot/Cobalt/Plugin/Silly/LOLCAT.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Bot::Cobalt::Plugin::Silly::LOLCAT;
2             $Bot::Cobalt::Plugin::Silly::LOLCAT::VERSION = '0.031001';
3 1     1   3471 use strictures 2;
  1         6  
  1         38  
4              
5 1     1   668 use POE::Filter::Stackable;
  1         2819  
  1         20  
6 1     1   1322 use POE::Filter::Line;
  1         1233  
  1         25  
7 1     1   184 use POE::Filter::LOLCAT;
  0            
  0            
8              
9             use Bot::Cobalt::Common;
10              
11             sub FILTER () { 0 }
12              
13             sub new { bless [undef], shift }
14              
15             sub Cobalt_register {
16             my ($self, $core) = splice @_, 0, 2;
17            
18             $core->plugin_register( $self, 'SERVER',
19             'public_cmd_lolcat'
20             );
21              
22            
23             $core->log->info("Loaded");
24             return PLUGIN_EAT_NONE
25             }
26              
27             sub Cobalt_unregister {
28             my ($self, $core) = splice @_, 0, 2;
29             $core->log->info("Unloaded");
30             return PLUGIN_EAT_NONE
31             }
32              
33             sub Bot_public_cmd_lolcat {
34             my ($self, $core) = splice @_, 0, 2;
35              
36             my $msg = ${ $_[0] };
37             my $context = $msg->context;
38              
39             my $str = decode_irc( join ' ', @{ $msg->message_array } );
40             $str ||= "Can I have a line to parse?";
41              
42             my $filter = $self->[FILTER] //= POE::Filter::Stackable->new(
43             Filters => [
44             POE::Filter::Line->new(),
45             POE::Filter::LOLCAT->new(),
46             ],
47             );
48              
49             $filter->get_one_start([$str."\n"]);
50              
51             my $lol = $filter->get_one;
52              
53             my $cat = shift @$lol;
54             chomp($cat);
55              
56             my $channel = $msg->channel;
57             $core->send_event( 'send_message',
58             $context,
59             $channel,
60             'LOLCAT: '.$cat
61             ) if $cat;
62            
63             return PLUGIN_EAT_ALL
64             }
65              
66             1;
67             __END__