Insult.pm

filter: Statementstmt 38.8% 14 / 36 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 32.2% 20 / 62 CC 10 SCAR 43.0
CC
10
Cov
26%
said
110.0
help
2.0
BEGIN
1.0
CRAP 73.7
« Excuse.pm ↑ Summary Zippy.pm »
1 package Bot::BasicBot::Pluggable::Module::Insult;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Bot::BasicBot::Pluggable::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw(Bot::BasicBot::Pluggable::Module);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #use Net::Telnet;
8 1 ▶use Lingua::Translate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 1 our %languages = (
12 'english' => 'en',
13 'chinese' => 'zh',
14 'french' => 'fr',
15 'german' => 'de',
16 'italian' => 'it',
17 'japanese' => 'ja',
18 'korean' => 'ko',
19 'portuguese' => 'pt',
20 'spanish' => 'es'
21 );
22  
23 0 ▶sub said {
Subroutine said: not called CC=10 SCAR=47.0
Pod documented
24 0 my ($self, $mess, $pri) = @_;
25  
26 0 my $body = $mess->{body};
27 0 my $who = $mess->{who};
28  
29 0 ▶ return unless ($pri == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless $pri == 2 0 0 0
30  
31  
32 0 ▶ return unless $body =~ /^\s*insult (.*)\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $body =~ /^\s*insult (.*)\s*$/ 0 0 0
33 0 my $person = $1;
34 0 my $language = "english";
35  
36 0 ▶ if ($person =~ s/ in ([a-z]+)\s*\w*\s*//i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($person =~ s/ in ([a-z]+)\s*\w*\s*//i) 0 0 0
37 0 $language = lc($1);
38 }
39
40 0 ▶ $person = $who if $person =~ /^\s*me\s*$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $person =~ /^\s*me\s*$/i 0 0 0
41  
42 0 my $insultgenerator = Acme::Scurvy::Whoreson::BilgeRat->new( language => 'insultserver' );
43  
44 0 my $insult = "$insultgenerator";
45  
46  
47 0 ▶ return "Errk, the insult code is mysteriously not working" unless defined $insult;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $insult 0 0 0
48  
49 0 ▶ $insult =~ s/^\s*You are/$person is/i if ($person ne $who);
Branch: 1 branch
BranchTrueFalseTotal
if $person ne $who 0 0 0
50  
51  
52 0 ▶ return $insult if $language eq 'english';
Branch: 1 branch
BranchTrueFalseTotal
if $language eq "english" 0 0 0
53  
54 0 ▶ my $xl8r = Lingua::Translate->new(src => "en", dest => $languages{$language})
Branch: 1 branch
BranchTrueFalseTotal
my $xl8r = "Lingua::Translate"->new("src", "en", "dest", $Bot::BasicBot::Pluggable::Module::Insult::languages{$language}) or return $insult 0 0 0
55 or return $insult;
56  
57 0 my $translated_insult;
58 0 eval {
59 0 $translated_insult = $xl8r->translate($insult);
60 };
61 0 ▶ $translated_insult = $insult if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
62  
63 0 return $translated_insult;
64  
65 }
66  
67 0 ▶sub help {
Subroutine help: not called CC=1 SCAR=6.9
Pod documented
68 0 return "Commands: 'insult <who> [in <language>]'";
69 }
70  
71 1 1;
72  
73  
74 __END__
« Excuse.pm ↑ Summary Zippy.pm »