File Coverage

blib/lib/Bot/Cobalt/Plugin/Silly/DailyFail.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Bot::Cobalt::Plugin::Silly::DailyFail;
2             $Bot::Cobalt::Plugin::Silly::DailyFail::VERSION = '0.031001';
3 1     1   3238 use strictures 2;
  1         6  
  1         94  
4              
5 1     1   722 use Acme::Daily::Fail 'get_headline';
  1         14369  
  1         70  
6              
7 1     1   196 use Bot::Cobalt::Common;
  0            
  0            
8              
9             sub new { bless [], shift }
10              
11             sub Cobalt_register {
12             my ($self, $core) = splice @_, 0, 2;
13            
14             $core->plugin_register( $self, 'SERVER',
15             'public_cmd_headline', 'public_cmd_dailyfail'
16             );
17            
18             $core->log->info("Loaded");
19              
20             return PLUGIN_EAT_NONE
21             }
22              
23             sub Cobalt_unregister {
24             my ($self, $core) = splice @_, 0, 2;
25              
26             $core->log->info("Unloaded");
27              
28             return PLUGIN_EAT_NONE
29             }
30              
31             sub Bot_public_cmd_dailyfail { Bot_public_cmd_headline(@_) }
32             sub Bot_public_cmd_headline {
33             my ($self, $core) = splice @_, 0, 2;
34              
35             my $msg = ${ $_[0] };
36             my $context = $msg->context;
37              
38             my $resp = get_headline();
39              
40             my $channel = $msg->channel;
41              
42             $core->send_event( 'send_message',
43             $context,
44             $channel,
45             "BREAKING: ".$resp
46             ) if $resp;
47            
48             return PLUGIN_EAT_ALL
49             }
50              
51             1;
52             __END__