File Coverage

blib/lib/Bot/Cobalt/Plugin/Silly/OutputLOLCAT.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::OutputLOLCAT;
2             $Bot::Cobalt::Plugin::Silly::OutputLOLCAT::VERSION = '0.031001';
3 1     1   3072 use strictures 2;
  1         4  
  1         29  
4              
5 1     1   142 use POE::Filter::Stackable;
  1         2  
  1         20  
6 1     1   5 use POE::Filter::Line;
  1         7  
  1         28  
7 1     1   236 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, 'USER',
19             'message'
20             );
21            
22             $core->log->info("Loaded");
23            
24             PLUGIN_EAT_NONE
25             }
26              
27             sub Cobalt_unregister {
28             my ($self, $core) = splice @_, 0, 2;
29            
30             $core->log->info("Unloaded");
31            
32             PLUGIN_EAT_NONE
33             }
34              
35             sub Outgoing_message {
36             my ($self, $core) = splice @_, 0, 2;
37              
38             my $filter = $self->[FILTER] //= POE::Filter::Stackable->new(
39             Filters => [
40             POE::Filter::Line->new(),
41             POE::Filter::LOLCAT->new(),
42             ],
43             );
44              
45             $filter->get_one_start([${$_[2]}."\n"]);
46              
47             my $lol = $filter->get_one;
48              
49             my $cat = shift @$lol;
50             chomp($cat);
51              
52             ${$_[2]} = $cat;
53              
54             PLUGIN_EAT_NONE
55             }
56              
57             1;
58             __END__