File Coverage

blib/lib/POE/Component/IRC/Plugin/Bollocks.pm
Criterion Covered Total %
statement 20 34 58.8
branch 0 4 0.0
condition n/a
subroutine 7 8 87.5
pod 1 4 25.0
total 28 50 56.0


line stmt bran cond sub pod time code
1             package POE::Component::IRC::Plugin::Bollocks;
2             $POE::Component::IRC::Plugin::Bollocks::VERSION = '1.02';
3             #ABSTRACT: A POE::Component::IRC plugin that talks bollocks.
4              
5 1     1   199015 use strict;
  1         2  
  1         25  
6 1     1   3 use warnings;
  1         1  
  1         23  
7 1     1   384 use Dev::Bollocks;
  1         50366  
  1         7  
8 1     1   282 use POE::Component::IRC::Plugin qw(:ALL);
  1         1  
  1         403  
9              
10             my @phrases = (
11             "So, let's ", 'We can ', 'We should ', 'Our mission is to ',
12             'Our job is to ', 'Your job is to ', 'And next we ', 'We better ',
13             'All of us plan to ', 'It is important to ', 'We were told to ',
14             'Our mission is to ', 'According to our plan we ');
15              
16             sub new {
17 1     1 1 4123 my $package = shift;
18 1         2 my %args = @_;
19 1         3 $args{lc $_} = delete $args{$_} for keys %args;
20 1         3 bless \%args, $package;
21             }
22              
23             sub PCI_register {
24 1     1 0 206 my ($self,$irc) = @_;
25 1         3 $irc->plugin_register( $self, 'SERVER', qw(public) );
26 1         21 return 1;
27             }
28              
29             sub PCI_unregister {
30 1     1 0 1328 return 1;
31             }
32              
33             sub S_public {
34 0     0 0   my ($self,$irc) = splice @_, 0, 2;
35 0           my ($nick,$userhost) = ( split /!/, ${ $_[0] } )[0..1];
  0            
36 0           my $channel = ${ $_[1] }->[0];
  0            
37 0           my $what = ${ $_[2] };
  0            
38 0           my $mynick = $irc->nick_name();
39 0           my ($command) = $what =~ m/^\s*\Q$mynick\E[\:\,\;\.]?\s*(.*)$/i;
40 0 0         return PCI_EAT_NONE unless $command;
41 0           my @cmd = split /\s+/, $command;
42 0 0         return PCI_EAT_NONE unless uc( $cmd[0] ) eq 'BOLLOCKS';
43 0           $irc->yield( privmsg =>
44             $channel =>
45             $phrases[int(rand(scalar @phrases))] . Dev::Bollocks->rand( int(rand(3) + 3)) );
46 0           return PCI_EAT_NONE;
47             }
48              
49             qq[It's all bollocks];
50              
51             __END__