Silly/LOLCAT.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Silly/DailyFail.pm ↑ Summary Silly/OutputLOLCAT.pm »
1 package Bot::Cobalt::Plugin::Silly::LOLCAT;
2 $Bot::Cobalt::Plugin::Silly::LOLCAT::VERSION = '0.031002';
3 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use POE::Filter::Stackable;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use POE::Filter::Line;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use POE::Filter::LOLCAT;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶use Bot::Cobalt::Common;
Subroutine BEGIN: called CC=1 SCAR=2.6
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__
« Silly/DailyFail.pm ↑ Summary Silly/OutputLOLCAT.pm »