blib/lib/Morris/Plugin/Log.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 32 CC 3 SCAR 14.6
CC
3
Cov
0%
should_handle_channel
6.0
handle_message
6.0
log_message
2.0
CRAP 4.3
1 package Morris::Plugin::Log;
2 use Moose;
3 use namespace::clean -except => qw(meta);
4  
5 extends 'Morris::Plugin';
6  
7 has channel => (
8 is => 'ro',
9 isa => 'Str',
10 required => 1,
11 );
12  
13 after register => sub {
14 my ($self, $conn) = @_;
15 $conn->register_hook( 'chat.privmsg', sub { $self->handle_message(@_) } );
16 };
17  
18 sub should_handle_channel {
19 my ($self, $message) = @_;
20 my $channel = $self->channel;
21 return 1 if $channel eq '*all*';
22 return $channel eq $message->channel;
23 }
24  
25 sub handle_message {
26 my ($self, $message) = @_;
27  
28 # make sure this is from the correct channel
29 if ( $self->should_handle_channel($message) ) {
30 $self->log_message($message);
31 }
32 }
33  
34 sub log_message {}
35  
36 __PACKAGE__->meta->make_immutable();
37  
38 1;