Amethyst/Brain/CNN.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 2 SCAR 11.0
CC
2
Cov
0%
think
6.0
init
2.0
BEGIN
2.0
CRAP 3.0
1 package Amethyst::Brain::CNN;
2  
3 use strict;
4 use vars qw(@ISA);
5 use URI;
6 use Amethyst::Brain;
7 use Amethyst::Message;
8  
9 @ISA = qw(Amethyst::Brain);
10  
11 sub init {
12 my $self = shift;
13 $self->{Content} = '';
14 }
15  
16 sub think {
17 my $self = shift;
18 my $message = shift;
19  
20 my $content = $message->content;
21  
22 if ($content !~ /[\.?!]\s*$/) {
23 $self->{Content} .= ' ' . $content;
24 return;
25 }
26  
27 $content = lc $self->{Content} . ' ' . $content;
28 $self->{Content} = '';
29  
30 # $content =~ s/\b(\w)\b/\u$1/g;
31 $content =~ s/\s+/ /g;
32 $content =~ s/^ //;
33 $content =~ s/ $//;
34  
35 local *::connections = $self->{Output};
36  
37 foreach my $connection (keys %::connections) {
38 my $reply = new Amethyst::Message(
39 Connection => $connection,
40 Channel => $::connections{$connection},
41 User => 'Amethyst',
42 Action => ACT_SAY,
43 Content => ucfirst $content,
44 );
45 $reply->send;
46 }
47  
48 return undef;
49 }
50  
51 1;