Amethyst/Brain/Eliza.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 57 CC 2 SCAR 9.8
CC
2
Cov
0%
think
6.0
init
2.0
DESTROY
2.0
CRAP 2.7
1 package Amethyst::Brain::Eliza;
2  
3 use strict;
4 use vars qw(@ISA);
5 use URI;
6 use Amethyst::Brain;
7 use Amethyst::Message;
8 use Chatbot::Eliza;
9  
10 @ISA = qw(Amethyst::Brain);
11  
12 sub init {
13 my $self = shift;
14 # $self->{Eliza} = new Chatbot::Eliza "Amethyst";
15 $self->{Eliza} = new Amethyst::Brain::Eliza::Core "Amethyst";
16 }
17  
18 sub think {
19 my $self = shift;
20 my $message = shift;
21  
22 my $content = $message->content;
23  
24 # return unless random(10) < 2;
25  
26 return undef unless
27 $content =~ /^Amethyst:/ ||
28 $message->channel eq 'tell';
29  
30 my $data = $self->{Eliza}->transform($message->content);
31  
32 my $reply = $message->reply($data);
33 # $reply->channel('spam') unless $message->channel eq 'tell';
34 $reply->send;
35  
36 return 1;
37 }
38  
39 package Amethyst::Brain::Eliza::Core;
40  
41 use strict;
42 use vars qw(@ISA);
43  
44 @ISA = qw(Chatbot::Eliza);
45  
46 sub DESTROY { } # Prevent this going to autoload
47  
48 1;