| 1 | package Horris::Connection::Plugin::Echo; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Echo Plugin on Horris | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | extends 'Horris::Connection::Plugin'; | |||||||||||||||||||||||||||||||
| 7 | 1 | with 'MooseX::Role::Pluggable::Plugin'; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | has '+is_enable' => ( | |||||||||||||||||||||||||||||||
| 10 | default => 0 | ||||||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub irc_privmsg { | ||||||||||||||||||||||||||||||
|
Subroutine
irc_privmsg: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 14 | 0 | my ($self, $message) = @_; | |||||||||||||||||||||||||||||||
| 15 | 0 | my $msg = $message->message; | |||||||||||||||||||||||||||||||
| 16 | 0 | my $botname = $self->connection->nickname; | |||||||||||||||||||||||||||||||
| 17 | 0 | my ($cmd) = $msg =~ m/^$botname\S*\s+(\w+)/; | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if (defined $cmd and lc $cmd eq 'echo') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $cmd and lc $cmd eq "echo"
MC/DC0%0/2
defined $cmd and lc $cmd eq "echo"
defined $cmd
lc $cmd eq "echo"
Truth table0%0/3
A and B
A= defined $cmdB= lc $cmd eq "echo"
| |||||||||||||||||||||||||||||||||
| 20 | 0 | $self->_switch; | |||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $self->connection->irc_notice({ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 22 | channel => $message->channel, | ||||||||||||||||||||||||||||||||
| 23 | message => $self->is_enable ? '[echo] on' : '[echo] off' | ||||||||||||||||||||||||||||||||
| 24 | }); | ||||||||||||||||||||||||||||||||
| 25 | } elsif ($self->is_enable) { | ||||||||||||||||||||||||||||||||
| 26 | 0 | $self->connection->irc_privmsg({ | |||||||||||||||||||||||||||||||
| 27 | channel => $message->channel, | ||||||||||||||||||||||||||||||||
| 28 | message => $message->from->nickname . ': ' . $msg | ||||||||||||||||||||||||||||||||
| 29 | }); | ||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 0 | return $self->pass; | |||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 1 | 1; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||||||||||||||