| 1 | package Bot::BasicBot::Pluggable::Module::Assemble; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Bot::BasicBot::Pluggable::Module; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Regexp::Assemble; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use vars qw( @ISA $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | @ISA = qw(Bot::BasicBot::Pluggable::Module); | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | $VERSION = '0.03'; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | sub told { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
told: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | my ( $self, $mess ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | my $bot = $self->bot(); | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # we must be directly addressed | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | if !( ( defined $mess->{address} && $mess->{address} eq $bot->nick() ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | ▶ | || $mess->{channel} eq 'msg' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick or $mess->{"channel"} eq "msg"
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick
MC/DC33%1/3
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick or $mess->{"channel"} eq "msg"
defined $mess->{"address"}
$mess->{"address"} eq $bot->nick
$mess->{"channel"} eq "msg"
Truth table60%3/5
A and B or C
A= defined $mess->{"address"}B= $mess->{"address"} eq $bot->nickC= $mess->{"channel"} eq "msg"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # ignore people we ignore | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | ▶ | return if $bot->ignore_nick( $mess->{who} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # only answer to our command (which can be our name too) | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | ▶ | my $src = $bot->nick() eq 'assemble' ? 'raw_body' : 'body'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | ▶ | return if $mess->{$src} !~ /^\s*assemble(.)(.*)/i; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # grab the parameter list | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | my ( $delim, $args ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | my @args = grep { $_ ne '' } split /\Q$delim\E+/, $args; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # ignore short lists | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | return if @args < 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # compute the assembled regexp and return it | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | return Regexp::Assemble->new()->add( @args )->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub help {'assemble regex1 regex2 regex3'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||