| 1 | package Net::IPMessenger::Bot; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use 5.008_005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | our $VERSION = '0.05'; | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Net::IPMessenger; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Net::IPMessenger::Bot::EventHandler; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 3 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 3 | my ( $class, %args ) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 3 | my $ipmsg = Net::IPMessenger->new( %{ $args{configure} } ); | |||||||||
| 15 | my $handler = Net::IPMessenger::Bot::EventHandler->new( | ||||||||||
| 16 | handler => $args{on_message}, | ||||||||||
| 17 | 3 | ); | |||||||||
| 18 | 3 | $ipmsg->add_event_handler($handler); | |||||||||
| 19 | |||||||||||
| 20 | 3 | my $self = bless { ipmsg => $ipmsg }, $class; | |||||||||
| 21 | 3 | $self->_set_signal_handlers; | |||||||||
| 22 | |||||||||||
| 23 | 3 | return $self; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub start { | ||||||||
|
Subroutine
start: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 27 | 0 | my $self = shift; | |||||||||
| 28 | 0 | $self->join(); | |||||||||
| 29 | 0 | ▶ | while ( $self->{ipmsg}->recv() ) { } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub join { | ||||||||
|
Subroutine
join: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 33 | 0 | my $self = shift; | |||||||||
| 34 | |||||||||||
| 35 | 0 | my $cmd = $self->{ipmsg}->messagecommand('BR_ENTRY')->set_broadcast; | |||||||||
| 36 | $self->{ipmsg}->send( | ||||||||||
| 37 | { | ||||||||||
| 38 | command => $cmd, | ||||||||||
| 39 | option => $self->{ipmsg}->my_info, | ||||||||||
| 40 | } | ||||||||||
| 41 | 0 | ); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 3 | ▶ | sub _set_signal_handlers { | ||||||||
|
Subroutine
_set_signal_handlers: called CC=1 SCAR=0.4
| |||||||||||
| 45 | 3 | my $self = shift; | |||||||||
| 46 | 0 | ▶ | $SIG{INT} = $SIG{TERM} = sub { $self->sighandle_INT() }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub sighandle_INT { | ||||||||
|
Subroutine
sighandle_INT: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 50 | 0 | my $self = shift; | |||||||||
| 51 | |||||||||||
| 52 | 0 | my $cmd = $self->{ipmsg}->messagecommand('BR_EXIT')->set_broadcast; | |||||||||
| 53 | 0 | $self->{ipmsg}->send( { command => $cmd } ); | |||||||||
| 54 | |||||||||||
| 55 | 0 | exit; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 1 | 1; | |||||||||
| 60 | __END__ | ||||||||||