| 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'} || ''
MC/DC0%0/1
$self->{'nick'} || ''
$self->{'nick'}
Truth table0%0/2
A
A= $self->{'nick'}
| |||||||||||||||||||||||||||||
| 30 | 0 | my $addressed = $mess->{address}; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return unless ($pri == 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (rand() < .5) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$addressed and $body =~ /you (rock|rocks|rewl|rule|are so+ co+l)/i
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
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if (rand() < .5) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$addressed and $body =~ /thank(s| you)/i
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
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (rand() < .5) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 65 | # 65% chance of replying to a random greeting when not addressed | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return if (!$addressed and rand() > 0.35); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $addressed and rand() > "0.35"
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"
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||