| 1 | package POEIKC::Plugin::IRC; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.00_02'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Class::Inspector; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use POE qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | Sugar::Args | ||||||||||||||||||||||||||||
| 11 | Loop::IO_Poll | ||||||||||||||||||||||||||||
| 12 | Component::IKC::Client | ||||||||||||||||||||||||||||
| 13 | Component::IRC::State | ||||||||||||||||||||||||||||
| 14 | Component::IRC::Plugin::AutoJoin | ||||||||||||||||||||||||||||
| 15 | 1 | ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use POEIKC::Daemon::Utility; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | sub spawn | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
spawn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 22 | 0 | my $self = { | |||||||||||||||||||||||||||
| 23 | @_ | ||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | bless $self,$class ; | |||||||||||||||||||||||||||
| 27 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($self); | |||||||||||||||||||||||||||
| 28 | 0 | my $session = POE::Session->create( | |||||||||||||||||||||||||||
| 29 | object_states => [ $self => Class::Inspector->methods(__PACKAGE__) ], | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | 0 | return $session->ID; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub _start { | ||||||||||||||||||||||||||
|
Subroutine
_start: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 35 | 0 | my $poe = sweet_args ; | |||||||||||||||||||||||||||
| 36 | 0 | my $kernel = $poe->kernel ; | |||||||||||||||||||||||||||
| 37 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 38 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 39 | 0 | my $alias = 'IKC_IRC'; | |||||||||||||||||||||||||||
| 40 | 0 | $kernel->alias_set($alias); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | $kernel->sig( HUP => '_stop' ); | |||||||||||||||||||||||||||
| 43 | 0 | $kernel->sig( INT => '_stop' ); | |||||||||||||||||||||||||||
| 44 | 0 | $kernel->sig( TERM => '_stop' ); | |||||||||||||||||||||||||||
| 45 | 0 | $kernel->sig( KILL => '_stop' ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | $kernel->call( | ||||||||||||||||||||||||||||
| 48 | IKC => | ||||||||||||||||||||||||||||
| 49 | publish => $alias, [ | ||||||||||||||||||||||||||||
| 50 | 0 | grep {/_respond$/} @{Class::Inspector->methods(__PACKAGE__)} | |||||||||||||||||||||||||||
| 51 | ], | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | POEIKC::Daemon::Utility::_DEBUG_log("alias_list"=>$kernel->alias_list()); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub _stop { | ||||||||||||||||||||||||||
|
Subroutine
_stop: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 58 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub test { | ||||||||||||||||||||||||||
|
Subroutine
test: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 64 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 65 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 66 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 67 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 68 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($kernel->alias_list()); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub message_respond { | ||||||||||||||||||||||||||
|
Subroutine
message_respond: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 75 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 76 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 77 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 78 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 79 | 0 | my ($request) = @{$poe->args}; | |||||||||||||||||||||||||||
| 80 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($request); | |||||||||||||||||||||||||||
| 81 | 0 | my ($param, $rsvp) = @{$request}; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($param); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | $kernel->yield(privmsg_notice=>$param); | |||||||||||||||||||||||||||
| 86 | 0 | $kernel->post( IKC => post => $rsvp, 1 ); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub status_respond { | ||||||||||||||||||||||||||
|
Subroutine
status_respond: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 91 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 92 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 93 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 94 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 95 | 0 | my ($request) = @{$poe->args}; | |||||||||||||||||||||||||||
| 96 | 0 | my ($param, $rsvp) = @{$request}; | |||||||||||||||||||||||||||
| 97 | 0 | $kernel->post( IKC => post => $rsvp, $object->{status} ); | |||||||||||||||||||||||||||
| 98 | #POEIKC::Daemon::Utility::_DEBUG_log($object); | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub privmsg_notice { | ||||||||||||||||||||||||||
|
Subroutine
privmsg_notice: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 104 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 105 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 106 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 107 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 108 | 0 | my $sender = $poe->sender ; | |||||||||||||||||||||||||||
| 109 | 0 | my $irc = $object->{irc}; | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | my ($pn, $conf, @msg) = (ref $poe->args->[0]->[0] eq 'HASH') ? (undef, @{$poe->args->[0]}) : @{$poe->args->[0]}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | @msg = @{$msg[0]} if ref $msg[0] eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $conf = eval $conf unless (ref $conf); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | $conf->{ lc $_ } = delete $conf->{$_} for keys %$conf; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($conf); | |||||||||||||||||||||||||||
| 117 | 0 | POEIKC::Daemon::Utility::_DEBUG_log("($pn, $conf, @msg)"); | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | my $irchost = $conf->{connect}->{server}; | |||||||||||||||||||||||||||
| 120 | 0 | my $channel = $conf->{channel}; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($irchost); | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | my @msglist; | |||||||||||||||||||||||||||
| 125 | 0 | ▶ | push @msglist, /\n/ ? split /\n/, $_ : $_ for(@msg); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $pn ||= @msglist > 1 ? 'notice' : 'privmsg'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pn ||= @msglist > 1 ? "notice" : "privmsg"
MC/DC0%0/2
$pn ||= @msglist > 1 ? "notice" : "privmsg"
$pn
@msglist > 1 ? "notice" : "privmsg"
Truth table0%0/3
A ||= B
A= $pnB= @msglist > 1 ? "notice" : "privmsg"
| |||||||||||||||||||||||||||||
| 127 | 0 | $pn = lc $pn; | |||||||||||||||||||||||||||
| 128 | SWITCH: { | ||||||||||||||||||||||||||||
| 129 | 0 | ▶ | ( not $object->{status}->{irc_connect} ) and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | $object->{status}->{irc_connect}++; | |||||||||||||||||||||||||||
| 131 | 0 | $object->{status}->{join}->{$channel}++; | |||||||||||||||||||||||||||
| 132 | 0 | $kernel->yield('irc_connect', $conf); | |||||||||||||||||||||||||||
| 133 | 0 | push @{$object->{status}->{msg}->{$channel}}, [$pn,\@msglist]; | |||||||||||||||||||||||||||
| 134 | 0 | last;}; | |||||||||||||||||||||||||||
| 135 | 0 | ▶ | (not $object->{status}->{join}->{$channel}) and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | $object->{status}->{join}->{$channel}++; | |||||||||||||||||||||||||||
| 137 | 0 | $irc->yield(join => $channel, $conf->{channel_key}); | |||||||||||||||||||||||||||
| 138 | 0 | push @{$object->{status}->{msg}->{$channel}}, [$pn,\@msglist]; | |||||||||||||||||||||||||||
| 139 | 0 | last;}; | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | (not $object->{status}->{joined}->{$channel}) and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | push @{$object->{status}->{msg}->{$channel}}, [$pn,\@msglist]; | |||||||||||||||||||||||||||
| 142 | 0 | last;}; | |||||||||||||||||||||||||||
| 143 | 0 | ▶ | (@{$object->{status}->{msg}->{$channel}} >= 1) and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | push @{$object->{status}->{msg}->{$channel}}, [$pn,\@msglist]; | |||||||||||||||||||||||||||
| 145 | 0 | last;}; | |||||||||||||||||||||||||||
| 146 | # else | ||||||||||||||||||||||||||||
| 147 | 0 | $kernel->yield(put=>$pn, $channel, \@msglist); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($object->{status}->{msg}); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub put { | ||||||||||||||||||||||||||
|
Subroutine
put: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 153 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 154 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 155 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 156 | 0 | my $irc = $object->{irc}; | |||||||||||||||||||||||||||
| 157 | 0 | my ($pn, $channel, $msg) = @{$poe->args}; | |||||||||||||||||||||||||||
| 158 | 0 | POEIKC::Daemon::Utility::_DEBUG_log("irc_join: ($pn, $channel, $msg)"); | |||||||||||||||||||||||||||
| 159 | 0 | $irc->yield($pn => $channel, $_) for @$msg; | |||||||||||||||||||||||||||
| 160 | #$irc->yield($pn => $channel, shift(@$msg)); | ||||||||||||||||||||||||||||
| 161 | #$kernel->delay(put => 0.1, $pn, $channel, $msg) if @$msg; | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub irc_connect { | ||||||||||||||||||||||||||
|
Subroutine
irc_connect: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 165 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 166 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 167 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 168 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 169 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 170 | 0 | my ($conf) = @{$poe->args}; | |||||||||||||||||||||||||||
| 171 | 0 | my $channel = $conf->{channel}; | |||||||||||||||||||||||||||
| 172 | 0 | my $key = $conf->{channel_key}; | |||||||||||||||||||||||||||
| 173 | 0 | POEIKC::Daemon::Utility::_DEBUG_log($channel); | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | my $irc = POE::Component::IRC::State->spawn( | ||||||||||||||||||||||||||||
| 176 | nick => 'poeikc_bot', | ||||||||||||||||||||||||||||
| 177 | username => 'poeikc_bot', | ||||||||||||||||||||||||||||
| 178 | ircname => 'poeikc_bot', | ||||||||||||||||||||||||||||
| 179 | server => 'localhost', | ||||||||||||||||||||||||||||
| 180 | port => '6667', | ||||||||||||||||||||||||||||
| 181 | #flood=>1, | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | %{$conf->{connect} || {}} | ||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'connect'} || {}
MC/DC0%0/1
$conf->{'connect'} || {}
$conf->{'connect'}
Truth table0%0/2
A
A= $conf->{'connect'}
| |||||||||||||||||||||||||||||
| 183 | ); | ||||||||||||||||||||||||||||
| 184 | $irc->plugin_add('AutoJoin', | ||||||||||||||||||||||||||||
| 185 | POE::Component::IRC::Plugin::AutoJoin->new( | ||||||||||||||||||||||||||||
| 186 | 0 | ▶ | Channels => $conf->{channel_key} ? {$channel=>$key} : [ $channel ], | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | ) | ||||||||||||||||||||||||||||
| 188 | ); | ||||||||||||||||||||||||||||
| 189 | 0 | $irc->yield(register => 'all'); | |||||||||||||||||||||||||||
| 190 | 0 | $irc->yield('connect'); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | my $irchost = $conf->{connect}->{server}; | |||||||||||||||||||||||||||
| 193 | 0 | $object->{irc} = $irc; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub irc_join { | ||||||||||||||||||||||||||
|
Subroutine
irc_join: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 199 | 0 | my $poe = sweet_args; | |||||||||||||||||||||||||||
| 200 | 0 | my $kernel = $poe->kernel; | |||||||||||||||||||||||||||
| 201 | 0 | my $heap = $poe->heap; | |||||||||||||||||||||||||||
| 202 | 0 | my $session = $poe->session ; | |||||||||||||||||||||||||||
| 203 | 0 | my $object = $poe->object ; | |||||||||||||||||||||||||||
| 204 | 0 | my $sender = $poe->sender ; | |||||||||||||||||||||||||||
| 205 | 0 | my $nick = (split /!/, $_[ARG0])[0]; | |||||||||||||||||||||||||||
| 206 | 0 | my $channel = $_[ARG1]; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | $object->{status}->{joined}->{$channel}++; | |||||||||||||||||||||||||||
| 209 | 0 | my $irc = $sender->get_heap(); | |||||||||||||||||||||||||||
| 210 | 0 | POEIKC::Daemon::Utility::_DEBUG_log("irc_join: $channel"); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ($nick eq $irc->nick_name()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if($object->{status}->{msg} and $object->{status}->{msg}->{$channel}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$object->{"status"}{"msg"} and $object->{"status"}{"msg"}{$channel}
MC/DC0%0/2
$object->{"status"}{"msg"} and $object->{"status"}{"msg"}{$channel}
$object->{"status"}{"msg"}
$object->{"status"}{"msg"}{$channel}
Truth table0%0/3
A and B
A= $object->{"status"}{"msg"}B= $object->{"status"}{"msg"}{$channel}
| |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | while ( my $ary = shift @{$object->{status}->{msg}->{$channel}} ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | my ($pn, $msg) = @$ary; | |||||||||||||||||||||||||||
| 216 | 0 | POEIKC::Daemon::Utility::_DEBUG_log("irc_join: ($pn, $msg)"); | |||||||||||||||||||||||||||
| 217 | 0 | $kernel->yield(put=>$pn, $channel, $msg); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1 | 1; | |||||||||||||||||||||||||||
| 226 | __END__ | ||||||||||||||||||||||||||||