| 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
| |||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | return unless $body =~ /^\s*insult (.*)\s*$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 37 | 0 | $language = lc($1); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | $person = $who if $person =~ /^\s*me\s*$/i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | $insult =~ s/^\s*You are/$person is/i if ($person ne $who); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | return $insult if $language eq 'english'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | my $xl8r = Lingua::Translate->new(src => "en", dest => $languages{$language}) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||