| 1 | package POE::Component::IRC::Plugin::MultiProxy::Recall; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $POE::Component::IRC::Plugin::MultiProxy::Recall::AUTHORITY = 'cpan:HINRIK'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | $POE::Component::IRC::Plugin::MultiProxy::Recall::VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use POE::Component::IRC::Common qw( parse_user ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use POE::Component::IRC::Plugin qw( :ALL ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use POE::Component::IRC::Plugin::BotTraffic; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use POE::Filter::IRCD; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Tie::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my ($package, %self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if (!$self{Mode} || $self{Mode} !~ /missed|all|none/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self{"Mode"} and $self{"Mode"} =~ /missed|all|none/
MC/DC0%0/2
$self{"Mode"} and $self{"Mode"} =~ /missed|all|none/
$self{"Mode"}
$self{"Mode"} =~ /missed|all|none/
Truth table0%0/3
A and B
A= $self{"Mode"}B= $self{"Mode"} =~ /missed|all|none/
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $self{Mode} = 'missed'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return bless \%self, $package; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub PCI_register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PCI_register: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self, $irc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (!$irc->isa('POE::Component::IRC::State')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | die __PACKAGE__ . " requires PoCo::IRC::State or a subclass thereof\n"; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (!grep { $_->isa('POE::Component::IRC::Plugin::BotTraffic') } values %{ $irc->plugin_list() }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $irc->plugin_add('BotTraffic', POE::Component::IRC::Plugin::BotTraffic->new()); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ($self->{state}) = grep { $_->isa('POE::Component::IRC::Plugin::MultiProxy::State') } values %{ $irc->plugin_list() }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{irc} = $irc; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->{filter} = POE::Filter::IRCD->new(); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->{recall} = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->{clients} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->{last_detach} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | tie @{ $self->{recall} }, 'Tie::File', scalar tempfile() if $self->{Mode} =~ /all|missed/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $irc->raw_events(1); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $irc->plugin_register($self, 'SERVER', qw(cap bot_ctcp_action bot_public connected ctcp_action msg public part proxy_authed proxy_close raw)); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub PCI_unregister { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PCI_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $irc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | delete $self->{irc}; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub S_cap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_cap: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $cmd = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($cmd eq 'ACK') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $list = ${ $_[1] } eq '*' ? ${ $_[2] } : ${ $_[1] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my @enabled = split / /, $list; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (grep { $_ =~ /^=?identify-msg$/ } @enabled) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->{idmsg} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (grep { $_ =~ /^-identify-msg$/ } @enabled) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->{idmsg} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub S_bot_ctcp_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_bot_ctcp_action: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $recipients = join (',', @{ ${ $_[0] } }); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $msg = ${ $_[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($self->{Mode} eq 'all') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $line = ':' . $irc->nick_long_form($irc->nick_name()) . " PRIVMSG $recipients :\x01ACTION $msg\x01"; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | push @{ $self->{recall} }, $line; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub S_bot_public { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_bot_public: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $recipients = join (',', @{ ${ $_[0] } }); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $msg = ${ $_[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($self->{Mode} eq 'all') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $line = ':' . $irc->nick_long_form($irc->nick_name()) . " PRIVMSG $recipients :$msg"; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | push @{ $self->{recall} }, $line; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub S_connected { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_connected: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self->{stash} = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->{stashing} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->{idmsg} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub S_ctcp_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_ctcp_action: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $sender = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $recipients = ${ $_[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $msg = ${ $_[2] }; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | for my $recipient (@{ $recipients }) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ($recipient eq $irc->nick_name()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | # private ACTION | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if (!$self->{clients}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $line = ":$sender PRIVMSG $irc->nick_name :\x01ACTION $msg\x01"; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | push @{ $self->{recall} }, $line; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ▶ | elsif ($self->{Mode} eq 'all' || $self->{Mode} eq 'missed' && !$self->{clients}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "missed" and not $self->{"clients"}
MC/DC0%0/3
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "all"
$self->{"Mode"} eq "missed"
not $self->{"clients"}
Truth table0%0/4
A or B and not(C)
A= $self->{"Mode"} eq "all"B= $self->{"Mode"} eq "missed"C= not $self->{"clients"}
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | # channel ACTION | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $line = ":$sender PRIVMSG $recipient :\x01ACTION $msg\x01"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | push @{ $self->{recall} }, $line; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub S_msg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_msg: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $sender = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $msg = ${ $_[2] }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return PCI_EAT_NONE if $self->{clients}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $line = ":$sender PRIVMSG $irc->nick_name :$msg"; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | push @{ $self->{recall} }, $line; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub S_part { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_part: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $chan = ${ $_[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (my $cycle = grep { $_->isa('POE::Component::IRC::Plugin::CycleEmpty') } values %{ $irc->plugin_list() } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | return PCI_EAT_NONE if $cycle->cycling($chan); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | # too CPU-heavy | ||||||||||||||||||||||||||||||||||||||||||
| 157 | # if ($self->{Mode} eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # # remove all messages related to this channel | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # my $input = $self->{filter}->get( $self->{recall} ); | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # for my $line (0..$#{ $self->{recall} }) { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # if (lc $input->[$line]{params}[0] eq lc $chan) { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # delete $self->{recall}[$line]; | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # elsif ($input->[$line]{command} =~ /332|333|366/ && lc $input->[$line]{params}[1] eq lc $chan) { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # delete $self->{recall}[$line]; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # elsif ($input->[$line]{command} eq '353' && lc $input->[$line]{params}->[2] eq lc $chan) { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # delete $self->{recall}[$line]; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub S_public { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_public: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $sender = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $chan = ${ $_[1] }->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $msg = ${ $_[2] }; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # do this here instead rather than in S_raw so that IDENTIFY-MSG | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # will by handled by POE::Filter::IRC::Compat | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($self->{Mode} eq 'all' || $self->{Mode} eq 'missed' && !$self->{clients}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "missed" and not $self->{"clients"}
MC/DC0%0/3
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "all"
$self->{"Mode"} eq "missed"
not $self->{"clients"}
Truth table0%0/4
A or B and not(C)
A= $self->{"Mode"} eq "all"B= $self->{"Mode"} eq "missed"C= not $self->{"clients"}
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | push @{ $self->{recall} }, ":$sender PRIVMSG $chan :$msg"; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub S_proxy_authed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_proxy_authed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->{clients}++; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub S_proxy_close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_proxy_close: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->{clients}--; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return if $self->{clients}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $self->{recall} = [ ] if $self->{Mode} =~ /^(?:missed|none)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($self->{Mode} eq 'missed') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | push @{ $self->{recall} }, $self->_chan_info(); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | elsif ($self->{Mode} eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->{last_detach} = $#{ $self->{recall} }; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub S_raw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
S_raw: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $raw_line = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $input = $self->{filter}->get( [ $raw_line ] )->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ($self->{stashing}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | # capture all numeric commands until we've got the MOTD | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ($input->{command} =~ /\d{3}/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | push @{ $self->{stash} }, $raw_line; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # RPL_ENDOFMOTD / ERR_NOMOTD | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($input->{command} =~ /376|422/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->{stashing} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($self->{Mode} eq 'all' || $self->{Mode} eq 'missed' && !$self->{clients}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "missed" and not $self->{"clients"}
MC/DC0%0/3
$self->{"Mode"} eq "all" or $self->{"Mode"} eq "missed" and not $self->{"clients"}
$self->{"Mode"} eq "all"
$self->{"Mode"} eq "missed"
not $self->{"clients"}
Truth table0%0/4
A or B and not(C)
A= $self->{"Mode"} eq "all"B= $self->{"Mode"} eq "missed"C= not $self->{"clients"}
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ($input->{command} eq 'MODE' && $input->{params}[1] =~ /^[#&+!]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$input->{"command"} eq "MODE" and $input->{"params"}[1] =~ /^[#&+!]/
MC/DC0%0/2
$input->{"command"} eq "MODE" and $input->{"params"}[1] =~ /^[#&+!]/
$input->{"command"} eq "MODE"
$input->{"params"}[1] =~ /^[#&+!]/
Truth table0%0/3
A and B
A= $input->{"command"} eq "MODE"B= $input->{"params"}[1] =~ /^[#&+!]/
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | # channel mode changes | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | push @{ $self->{recall} }, $raw_line; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | elsif ($input->{command} =~ /JOIN|KICK|PART|QUIT|NICK|TOPIC/) { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # other channel-related things | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | push @{ $self->{recall} }, $raw_line; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | elsif ($input->{command} eq '353') { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # only log this when we've just joined the channel | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | push @{ $self->{recall} }, $raw_line if $self->{state}->is_syncing($input->{params}[2]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | elsif ($input->{command} =~ /332|333|366/) { | ||||||||||||||||||||||||||||||||||||||||||
| 244 | # only log these when we've just joined the channel | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | push @{ $self->{recall} }, $raw_line if $self->{state}->is_syncing($input->{params}[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | # returns everything that an IRC server would send us upon joining | ||||||||||||||||||||||||||||||||||||||||||
| 253 | # the channels we're on | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub _chan_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chan_info: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $irc = $self->{irc}; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $state = $self->{state}; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $me = $irc->nick_name(); | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my @info; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | for my $chan (keys %{ $irc->channels() }) { | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | push @info, ':' . $irc->nick_long_form($me) . " JOIN :$chan"; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | push @info, $state->topic_reply($chan) if keys %{ $irc->channel_topic($chan) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | push @info, $state->names_reply($chan); | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return @info; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub recall { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recall: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $irc = $self->{irc}; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $me = $irc->nick_name(); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $server = $irc->server_name(); | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | for my $line (@{ $self->{stash} }) { | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $line =~ s/^(\S+ +\S+) +\S+ +(.*)/$1 $me $2/; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | push @lines, $line; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | push @lines, ":$server MODE $me :" . $irc->umode() if $irc->umode(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | push @lines, @{ $self->{recall} }; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | push @lines, ":$server CAP * ACK :identify-msg" if $self->{idmsg}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($self->{Mode} eq 'all' && $#{ $self->{recall} } > $self->{last_detach}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->{"Mode"} eq "all" and $#{$$self{"recall"};} > $self->{"last_detach"}
MC/DC0%0/2
$self->{"Mode"} eq "all" and $#{$$self{"recall"};} > $self->{"last_detach"}
$self->{"Mode"} eq "all"
$#{$$self{"recall"};} > $self->{"last_detach"}
Truth table0%0/3
A and B
A= $self->{"Mode"} eq "all"B= $#{$$self{"recall"};} > $self->{"last_detach"}
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | # remove all PMs received since we last detached | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | for my $line ($self->{last_detach} .. $#{ $self->{recall} }) { | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $in = shift @{ $self->{filter}->get( $self->{recall} ) }; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($in->{command} eq 'PRIVMSG' && $in->{params}[0] !~ /^[#&+!]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$in->{"command"} eq "PRIVMSG" and not $in->{"params"}[0] =~ /^[#&+!]/
MC/DC0%0/2
$in->{"command"} eq "PRIVMSG" and not $in->{"params"}[0] =~ /^[#&+!]/
$in->{"command"} eq "PRIVMSG"
not $in->{"params"}[0] =~ /^[#&+!]/
Truth table0%0/3
A and not(B)
A= $in->{"command"} eq "PRIVMSG"B= not $in->{"params"}[0] =~ /^[#&+!]/
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | delete $self->{recall}[$line]; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif ($self->{Mode} eq 'none') { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | push @lines, $self->_chan_info(); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | POE::Compoent::IRC::Plugin::MultiProxy::Recall - A PoCo-IRC plugin which can greet proxy clients with the messages they missed while they were away | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | use POE::Compoent::IRC::Plugin::MultiProxy::Recall; | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | $irc->plugin_add('Recall', POE::Compoent::IRC::Plugin::MultiProxy::Recall->new( Mode => 'missed' )); | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | This plugin requires the IRC component to be | ||||||||||||||||||||||||||||||||||||||||||
| 319 | L<POE::Component::IRC::State|POE::Component::IRC::State> or a subclass thereof. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | It also requires a | ||||||||||||||||||||||||||||||||||||||||||
| 321 | L<POE::Component::IRC::Plugin::BotTraffic|POE::Component::IRC::Plugin::BotTraffic> | ||||||||||||||||||||||||||||||||||||||||||
| 322 | to be in the plugin pipeline. It will be added automatically if it is not present. | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | =head2 C<new> | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | One optional argument: | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | B<'Mode'>, which public messages you want it to recall. B<'missed'>, the | ||||||||||||||||||||||||||||||||||||||||||
| 331 | default, makes it only recall public messages that were received while no | ||||||||||||||||||||||||||||||||||||||||||
| 332 | proxy client was attached. B<'all'> will recall public messages from all | ||||||||||||||||||||||||||||||||||||||||||
| 333 | channels since they were joined. B<'none'> will recall none. The plugin will | ||||||||||||||||||||||||||||||||||||||||||
| 334 | always recall missed private messages, regardless of this option. | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | Returns a plugin object suitable for feeding to | ||||||||||||||||||||||||||||||||||||||||||
| 337 | L<POE::Component::IRC|POE::Component::IRC>'s C<plugin_add()> method. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | =cut | ||||||||||||||||||||||||||||||||||||||||||