File Coverage

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