Amethyst/Brain/Infobot/Module/Zappa.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 46 CC 2 SCAR 10.6
CC
2
Cov
0%
quote
6.0
new
2.0
action
2.0
CRAP 2.9
1 package Amethyst::Brain::Infobot::Module::Zappa;
2  
3 use strict;
4 use vars qw(@ISA);
5 use Amethyst::Message;
6 use Amethyst::Brain::Infobot;
7 use Amethyst::Brain::Infobot::Module;
8  
9 @ISA = qw(Amethyst::Brain::Infobot::Module);
10  
11 sub new {
12 my $class = shift;
13 my $self = $class->SUPER::new(
14 Name => 'Zappa',
15 Regex => qr/^(be zappa)$/i,
16 Usage => 'be zappa',
17 Description => "gives you a random quote from " .
18 "Frank Zappa",
19 @_
20 );
21  
22 return bless $self, $class;
23 }
24  
25 sub action {
26 my ($self, $message) = @_;
27  
28 my $reply = $self->reply_to($message, $self->quote());
29 $reply->send;
30  
31 return 1;
32 }
33  
34 sub quote {
35 my $self = shift;
36  
37 unless ($self->{quotes}) {
38 while (<DATA>) {
39 chomp;
40 push @{$self->{quotes}}, $_;
41 }
42 }
43  
44 my $y = $self->{quotes}->[rand(@{$self->{quotes}})];
45  
46 return $y;
47 }
48  
49 1;
50  
51 __DATA__