Botsnack.pm

filter: Statementstmt 32.4% 12 / 37 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 20.7% 17 / 82 CC 15 SCAR 52.5
CC
15
Cov
18%
said
240.0
help
2.0
BEGIN
1.0
CRAP 189.7
↑ Summary Nickometer.pm »
1 package Bot::BasicBot::Pluggable::Module::Botsnack;
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 # ways to say hello
8 1 my @hello = ('hello',
9 'hi',
10 'hey',
11 'niihau',
12 'bonjour',
13 'hola',
14 'salut',
15 'que tal',
16 'privet',
17 "what's up");
18  
19 # things to say when people thank me
20 1 my @welcomes = ('no problem', 'my pleasure', 'sure thing',
21 'no worries', 'de nada', 'de rien', 'bitte', 'pas de quoi');
22  
23 0 ▶sub said {
Subroutine said: not called CC=15 SCAR=54.8
Pod documented
24 0 my ($self, $mess, $pri) = @_;
25  
26 0 my $body = $mess->{body};
27 0 my $who = $mess->{who};
28  
29 0 ▶ my $nick = $self->{nick} || "";
Condition0%0/2
$self->{'nick'} || ''
l!l
00
MC/DC0%0/1
$self->{'nick'} || ''
$self->{'nick'}
Truth table0%0/2
A
A= $self->{'nick'}
Aresult
11
00
30 0 my $addressed = $mess->{address};
31  
32 0 ▶ return unless ($pri == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless $pri == 2 0 0 0
33  
34 # Gotta be gender-neutral here... we're sensitive to the bot's needs. :-)
35 0 ▶ if ($body =~ /(good(\s+fuckin[\'g]?)?\s+(bo(t|y)|g([ui]|r+)rl))|(bot(\s|\-)?snack)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ /(good(\s+fuckin[\'g]?)?\s+(bo(t|y)|g([ui]|r+)rl))|(bot(\s|\-)?snack)/i) 0 0 0
36 0 ▶ if (rand() < .5) {
Branch: 1 branch
BranchTrueFalseTotal
if (rand() < 0.5) { } 0 0 0
37 0 return "thanks $who :)";
38 } else {
39 0 return ":)";
40 }
41 }
42  
43 0 ▶ if ($addressed && $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addressed and $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i) 0 0 0
Condition0%0/3
$addressed and $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i
!ll&&!rl&&r
000
MC/DC0%0/2
$addressed and $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i
$addressed $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i
Truth table0%0/3
A and B
A= $addressedB= $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i
ABresult
0X0
100
111
44 0 ▶ if (rand() < .5) {
Branch: 1 branch
BranchTrueFalseTotal
if (rand() < 0.5) { } 0 0 0
45 0 return "thanks $who :)";
46 } else {
47 0 return ":)";
48 }
49 }
50  
51 0 ▶ if ($addressed && $body =~ /thank(s| you)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addressed and $body =~ /thank(s| you)/i) 0 0 0
Condition0%0/3
$addressed and $body =~ /thank(s| you)/i
!ll&&!rl&&r
000
MC/DC0%0/2
$addressed and $body =~ /thank(s| you)/i
$addressed $body =~ /thank(s| you)/i
Truth table0%0/3
A and B
A= $addressedB= $body =~ /thank(s| you)/i
ABresult
0X0
100
111
52 0 ▶ if (rand() < .5) {
Branch: 1 branch
BranchTrueFalseTotal
if (rand() < 0.5) { } 0 0 0
53 0 return $welcomes[int(rand(@welcomes))]." who";
54 } else {
55 0 return "$who: ".$welcomes[int(rand(@welcomes))];
56 }
57 }
58  
59  
60 0 ▶ if ($body =~ /(\bayb\b)|(all your base)|(all your \w+ belong)|(someone set us up the bomb)|(^\s*hello gentlemen\s*$)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ /(\bayb\b)|(all your base)|(all your \w+ belong)|(someone set us up the bomb)|(^\s*hello gentlemen\s*$)/i) 0 0 0
61 0 return "$who - All Your Base references are verboten. You may be kicked...this is not personal..come back soon";
62 }
63  
64 0 ▶ if ($body =~ /^\s*(h(ello|i( there)?|owdy|ey|ola)|salut|bonjour|niihau|que\s*tal)( $nick)?\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ /^\s*(h(ello|i( there)?|owdy|ey|ola)|salut|bonjour|niihau|que\s*tal)( $nick)?\s*$/i) 0 0 0
65 # 65% chance of replying to a random greeting when not addressed
66 0 ▶ return if (!$addressed and rand() > 0.35);
Branch: 1 branch
BranchTrueFalseTotal
if not $addressed and rand() > "0.35" 0 0 0
Condition0%0/3
not $addressed and rand() > "0.35"
!ll&&!rl&&r
000
MC/DC0%0/2
not $addressed and rand() > "0.35"
not $addressed rand() > "0.35"
Truth table0%0/3
not(A) and B
A= not $addressedB= rand() > "0.35"
ABresult
0X0
100
111
67  
68 0 my($r) = $hello[int(rand(@hello))];
69 0 return "$r, $who";
70 }
71  
72
73  
74 }
75  
76 0 ▶sub help {
Subroutine help: not called CC=1 SCAR=6.9
Pod documented
77 0 return "Commands: 'botsnack'";
78 }
79  
80 1 1;
81  
82 __END__
↑ Summary Nickometer.pm »