| 1 | package POE::Filter::IRC::Compat; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 80 | $POE::Filter::IRC::Compat::VERSION = '6.95'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 80 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 80 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 80 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 80 | ▶ | use POE::Filter::IRCD; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 80 | ▶ | use File::Basename qw(fileparse); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 80 | ▶ | use base qw(POE::Filter); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | my %irc_cmds = ( | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 2018 | ▶ | qr/^\d{3}$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2018 | my ($self, $event, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2018 | $event->{args}->[0] = _decolon( $line->{prefix} ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 2018 | shift @{ $line->{params} }; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 2018 | ▶ | if ( $line->{params}->[0] && $line->{params}->[0] =~ /\x20/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line->{"params"}[0] and $line->{"params"}[0] =~ /\x20/
MC/DC100%2/2
$line->{"params"}[0] and $line->{"params"}[0] =~ /\x20/
$line->{"params"}[0]
$line->{"params"}[0] =~ /\x20/
Truth table100%3/3
A and B
A= $line->{"params"}[0]B= $line->{"params"}[0] =~ /\x20/
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1183 | $event->{args}->[1] = $line->{params}->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 835 | ▶ | $event->{args}->[1] = join(' ', ( map { /\x20/ ? ":$_" : $_ } @{ $line->{params} } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 2018 | $event->{args}->[2] = $line->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | qr/^cap$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | my ($self, $event, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | for (my $i = 0; ; $i++) { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 9 | ▶ | last if !defined $line->{params}[$i+1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | $event->{args}[$i] = $line->{params}[$i+1]; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 29 | ▶ | qr/^notice$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 29 | my ($self, $event, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 29 | ▶ | if (defined $line->{prefix} && $line->{prefix} =~ /!/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $line->{"prefix"} and $line->{"prefix"} =~ /!/
MC/DC100%2/2
defined $line->{"prefix"} and $line->{"prefix"} =~ /!/
defined $line->{"prefix"}
$line->{"prefix"} =~ /!/
Truth table100%3/3
A and B
A= defined $line->{"prefix"}B= $line->{"prefix"} =~ /!/
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | $event->{args} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 36 | _decolon( $line->{prefix} ), | ||||||||||||||||||||||||||||||||||||||||||
| 37 | [split /,/, $line->{params}->[0]], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ($self->{identifymsg} | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ? _split_idmsg($line->{params}->[1]) | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 21 | ▶ | : $line->{params}->[1] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | $event->{name} = 'snotice'; | |||||||||||||||||||||||||||||||||||||||||
| 46 | $event->{args} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 47 | $line->{params}->[1], | ||||||||||||||||||||||||||||||||||||||||||
| 48 | $line->{params}->[0], | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | (defined $line->{prefix} ? _decolon($line->{prefix}) : ()), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 55 | ▶ | qr/^privmsg$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 55 | my ($self, $event, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 55 | ▶ | if ( grep { index( $line->{params}->[0], $_ ) >= 0 } @{ $self->{chantypes} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | $event->{args} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 57 | _decolon( $line->{prefix} ), | ||||||||||||||||||||||||||||||||||||||||||
| 58 | [split /,/, $line->{params}->[0]], | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ($self->{identifymsg} | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ? _split_idmsg($line->{params}->[1]) | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 45 | ▶ | : $line->{params}->[1] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 45 | $event->{name} = 'public'; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | $event->{args} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 68 | _decolon( $line->{prefix} ), | ||||||||||||||||||||||||||||||||||||||||||
| 69 | [split /,/, $line->{params}->[0]], | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ($self->{identifymsg} | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ? _split_idmsg($line->{params}->[1]) | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | ▶ | : $line->{params}->[1] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | $event->{name} = 'msg'; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | qr/^invite$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | my ($self, $event, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | shift( @{ $line->{params} } ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | unshift( @{ $line->{params} }, _decolon( $line->{prefix} || '' ) ) if $line->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$line->{'prefix'} || ''
MC/DC0%0/1
$line->{'prefix'} || ''
$line->{'prefix'}
Truth table50%1/2
A
A= $line->{'prefix'}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | $event->{args} = $line->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 80 | ); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # the magic cookie jar | ||||||||||||||||||||||||||||||||||||||||||
| 87 | my %dcc_types = ( | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 9 | ▶ | qr/^(?:CHAT|SEND)$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 9 | my ($nick, $type, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 9 | my ($file, $addr, $port, $size); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | return if !(($file, $addr, $port, $size) = $args =~ /^(".+"|[^ ]+) +(\d+) +(\d+)(?: +(\d+))?/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | ▶ | if ($file =~ s/^"//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $file =~ s/"$//; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | $file =~ s/\\"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | $file = fileparse($file); | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 9 | $port, | |||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | nick => $nick, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | file => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | addr => $addr, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $file, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | $size, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | $addr, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | qr/^(?:ACCEPT|RESUME)$/ => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my ($nick, $type, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | my ($file, $port, $position); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | return if !(($file, $port, $position) = $args =~ /^(".+"|[^ ]+) +(\d+) +(\d+)/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $file =~ s/^"|"$//g; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | $file = fileparse($file); | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | $port, | |||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | nick => $nick, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | file => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | size => $position, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | $file, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | $position, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 80 | ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 124 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 124 | my ($package, %self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 124 | $self{lc $_} = delete $self{$_} for keys %self; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 124 | $self{BUFFER} = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 124 | $self{_ircd} = POE::Filter::IRCD->new(); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 124 | ▶ | $self{chantypes} = [ '#', '&' ] if ref $self{chantypes} ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 124 | return bless \%self, $package; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $nself = { }; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $nself->{$_} = $self->{$_} for keys %{ $self }; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $nself->{BUFFER} = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return bless $nself, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | # Set/clear the 'debug' flag. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($self, $flag) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (defined $flag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->{debug} = $flag; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->{_ircd}->debug($flag); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $self->{debug}; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 181 | ▶ | sub chantypes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chantypes: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 181 | my ($self, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 181 | ▶ | return if ref $ref ne 'ARRAY' || !@{ $ref }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $ref ne "ARRAY" or not @{$ref;}
MC/DC0%0/2
ref $ref ne "ARRAY" or not @{$ref;}
ref $ref ne "ARRAY"
not @{$ref;}
Truth table33%1/3
A or not(B)
A= ref $ref ne "ARRAY"B= not @{$ref;}
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 181 | $self->{chantypes} = $ref; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 181 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 91 | ▶ | sub identifymsg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
identifymsg: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 91 | my ($self, $switch) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 91 | $self->{identifymsg} = $switch; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 91 | return; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub _split_idmsg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_idmsg: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my ($identified, $msg) = split //, $line, 2; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $identified = $identified eq '+' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return $msg, $identified; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 3309 | ▶ | sub get_one { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_one: called CC=12 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 3309 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 3309 | ▶ | my $line = shift @{ $self->{BUFFER} } or return [ ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2595 | ▶ | if (ref $line ne 'HASH' || !$line->{command} || !$line->{params}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $line ne "HASH" or not $line->{"command"} or not $line->{"params"}
ref $line ne "HASH" or not $line->{"command"}
MC/DC0%0/3
ref $line ne "HASH" or not $line->{"command"} or not $line->{"params"}
ref $line ne "HASH"
not $line->{"command"}
not $line->{"params"}
Truth table25%1/4
A or not(B) or not(C)
A= ref $line ne "HASH"B= not $line->{"command"}C= not $line->{"params"}
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | warn "Received line '$line' that is not IRC protocol\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 2595 | ▶ | if ($line->{command} =~ /^PRIVMSG|NOTICE$/ && $line->{params}->[1] =~ tr/\001//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line->{"command"} =~ /^PRIVMSG|NOTICE$/ and $line->{"params"}[1] =~ tr/\cA//
MC/DC100%2/2
$line->{"command"} =~ /^PRIVMSG|NOTICE$/ and $line->{"params"}[1] =~ tr/\cA//
$line->{"command"} =~ /^PRIVMSG|NOTICE$/
$line->{"params"}[1] =~ tr/\cA//
Truth table100%3/3
A and B
A= $line->{"command"} =~ /^PRIVMSG|NOTICE$/B= $line->{"params"}[1] =~ tr/\cA//
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 34 | return $self->_get_ctcp($line); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | my $event = { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | name => lc $line->{command}, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | raw_line => $line->{raw_line}, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 2561 | }; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 2561 | for my $cmd (keys %irc_cmds) { | |||||||||||||||||||||||||||||||||||||||||
| 205 | 9406 | ▶ | if ($event->{name} =~ $cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 2108 | $irc_cmds{$cmd}->($self, $event, $line); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 2108 | return [ $event ]; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # default | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 453 | ▶ | unshift( @{ $line->{params} }, _decolon( $line->{prefix} || '' ) ) if $line->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$line->{'prefix'} || ''
MC/DC0%0/1
$line->{'prefix'} || ''
$line->{'prefix'}
Truth table50%1/2
A
A= $line->{'prefix'}
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 453 | $event->{args} = $line->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 453 | return [ $event ]; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 2595 | ▶ | sub get_one_start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_one_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 2595 | my ($self, $lines) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 2595 | push @{ $self->{BUFFER} }, @$lines; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 2595 | return; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 27 | ▶ | sub put { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 27 | my ($self, $lineref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 27 | my $quoted = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 27 | push @$quoted, _ctcp_quote($_) for @$lineref; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 27 | return $quoted; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # Properly CTCP-quotes a message. Whoop. | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 27 | ▶ | sub _ctcp_quote { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ctcp_quote: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 27 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 27 | $line = _low_quote( $line ); | |||||||||||||||||||||||||||||||||||||||||
| 235 | #$line =~ s/\\/\\\\/g; | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 27 | $line =~ s/\001/\\a/g; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 27 | return "\001$line\001"; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # Splits a message into CTCP and text chunks. This is gross. Most of | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # this is also stolen from Net::IRC, but I (fimm) wrote that too, so it's | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # used with permission. ;-) | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 34 | ▶ | sub _ctcp_dequote { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ctcp_dequote: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 34 | my ($msg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 34 | my (@chunks, $ctcp, $text); | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # CHUNG! CHUNG! CHUNG! | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 34 | ▶ | if (!defined $msg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | croak 'Not enough arguments to POE::Filter::IRC::Compat::_ctcp_dequote'; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # Strip out any low-level quoting in the text. | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 34 | $msg = _low_dequote( $msg ); | |||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | # Filter misplaced \001s before processing... (Thanks, tchrist!) | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 34 | ▶ | substr($msg, rindex($msg, "\001"), 1, '\\a') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | if ($msg =~ tr/\001//) % 2 != 0; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 34 | ▶ | return if $msg !~ tr/\001//; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 33 | @chunks = split /\001/, $msg; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 33 | ▶ | shift @chunks if !length $chunks[0]; # FIXME: Is this safe? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 33 | for (@chunks) { | |||||||||||||||||||||||||||||||||||||||||
| 267 | # Dequote unnecessarily quoted chars, and convert escaped \'s and ^A's. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 35 | s/\\([^\\a])/$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 35 | s/\\\\/\\/g; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 35 | s/\\a/\001/g; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | # If the line begins with a control-A, the first chunk is a CTCP | ||||||||||||||||||||||||||||||||||||||||||
| 274 | # message. Otherwise, it starts with text and alternates with CTCP | ||||||||||||||||||||||||||||||||||||||||||
| 275 | # messages. Really stupid protocol. | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 33 | ▶ | if ($msg =~ /^\001/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 33 | push @$ctcp, shift @chunks; | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 33 | ▶ | while (@chunks) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | push @$text, shift @chunks; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | push @$ctcp, shift @chunks if @chunks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 33 | return ($ctcp, $text); | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 2461 | ▶ | sub _decolon { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decolon: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 2461 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 2461 | $line =~ s/^://; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 2461 | return $line; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | ## no critic (Subroutines::ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 34 | ▶ | sub _get_ctcp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_ctcp: called CC=25 SCAR=46.4
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 34 | my ($self, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | # Is this a CTCP request or reply? | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 34 | ▶ | my $ctcp_type = $line->{command} eq 'PRIVMSG' ? 'ctcp' : 'ctcpreply'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # CAPAP IDENTIFY-MSG is only applied to ACTIONs | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 34 | my ($msg, $identified) = ($line->{params}->[1], undef); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 34 | ▶ | ($msg, $identified) = _split_idmsg($msg) if $self->{identifymsg} && $msg =~ /^.ACTION/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"identifymsg"} and $msg =~ /^.ACTION/
MC/DC0%0/2
$self->{"identifymsg"} and $msg =~ /^.ACTION/
$self->{"identifymsg"}
$msg =~ /^.ACTION/
Truth table33%1/3
A and B
A= $self->{"identifymsg"}B= $msg =~ /^.ACTION/
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 34 | my $events = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 34 | my ($ctcp, $text) = _ctcp_dequote($msg); | |||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 34 | ▶ | if (!defined $ctcp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | ▶ | warn "Received malformed CTCP message: $msg\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | return $events; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 33 | ▶ | my $nick = defined $line->{prefix} ? (split /!/, $line->{prefix})[0] : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | # We only process the first CTCP. The only people who send multiple ones | ||||||||||||||||||||||||||||||||||||||||||
| 317 | # are those who are trying to flood our outgoing queue anyway (e.g. by | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # having us reply to 20 VERSION requests at a time). | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 33 | my ($name, $args); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 33 | CTCP: for my $string ($ctcp->[0]) { | |||||||||||||||||||||||||||||||||||||||||
| 321 | 33 | ▶ | if (!(($name, $args) = $string =~ /^(\w+)(?: +(.*))?/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | defined $nick | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | ? do { warn "Received malformed CTCP message from $nick: $string\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | : do { warn "Trying to send malformed CTCP message: $string\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | last CTCP; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 33 | ▶ | if (lc $name eq 'dcc') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 11 | my ($dcc_type, $rest); | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 11 | ▶ | if (!(($dcc_type, $rest) = $args =~ /^(\w+) +(.+)/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | defined $nick | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | ? do { warn "Received malformed DCC request from $nick: $args\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | : do { warn "Trying to send malformed DCC request: $args\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | last CTCP; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 11 | $dcc_type = uc $dcc_type; | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 11 | my ($handler) = grep { $dcc_type =~ /$_/ } keys %dcc_types; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 11 | ▶ | if (!$handler) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | warn "Unhandled DCC $dcc_type request: $rest\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | last CTCP; | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 11 | my @dcc_args = $dcc_types{$handler}->($nick, $dcc_type, $rest); | |||||||||||||||||||||||||||||||||||||||||
| 349 | 11 | ▶ | if (!@dcc_args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | defined $nick | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | ? do { warn "Received malformed DCC $dcc_type request from $nick: $rest\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | : do { warn "Trying to send malformed DCC $dcc_type request: $rest\n" if $self->{debug} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | last CTCP; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | push @$events, { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | name => 'dcc_request', | ||||||||||||||||||||||||||||||||||||||||||
| 359 | args => [ | ||||||||||||||||||||||||||||||||||||||||||
| 360 | $line->{prefix}, | ||||||||||||||||||||||||||||||||||||||||||
| 361 | $dcc_type, | ||||||||||||||||||||||||||||||||||||||||||
| 362 | @dcc_args, | ||||||||||||||||||||||||||||||||||||||||||
| 363 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 364 | raw_line => $line->{raw_line}, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | push @$events, { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | name => $ctcp_type . '_' . lc $name, | ||||||||||||||||||||||||||||||||||||||||||
| 370 | args => [ | ||||||||||||||||||||||||||||||||||||||||||
| 371 | $line->{prefix}, | ||||||||||||||||||||||||||||||||||||||||||
| 372 | [split /,/, $line->{params}->[0]], | ||||||||||||||||||||||||||||||||||||||||||
| 373 | (defined $args ? $args : ''), | ||||||||||||||||||||||||||||||||||||||||||
| 374 | (defined $identified ? $identified : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 375 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 376 | raw_line => $line->{raw_line}, | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 22 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | # XXX: I'm not quite sure what this is for, but on FreeNode it adds an | ||||||||||||||||||||||||||||||||||||||||||
| 382 | # extra bogus event and displays a debug message, so I have disabled it. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # FreeNode precedes PRIVMSG and CTCP ACTION messages with '+' or '-'. | ||||||||||||||||||||||||||||||||||||||||||
| 384 | #if ($text && @$text) { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | # my $what; | ||||||||||||||||||||||||||||||||||||||||||
| 386 | # ($what) = $line->{raw_line} =~ /^(:[^ ]+ +\w+ +[^ ]+ +)/ | ||||||||||||||||||||||||||||||||||||||||||
| 387 | # or warn "What the heck? '".$line->{raw_line}."'\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||
| 388 | # $text = (defined $what ? $what : '') . ':' . join '', @$text; | ||||||||||||||||||||||||||||||||||||||||||
| 389 | # $text =~ s/\cP/^P/g; | ||||||||||||||||||||||||||||||||||||||||||
| 390 | # warn "CTCP: $text\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||
| 391 | # push @$events, @{ $self->{_ircd}->get([$text]) }; | ||||||||||||||||||||||||||||||||||||||||||
| 392 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 33 | return $events; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | # Quotes a string in a low-level, protocol-safe, utterly brain-dead | ||||||||||||||||||||||||||||||||||||||||||
| 398 | # fashion. Returns the quoted string. | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 27 | ▶ | sub _low_quote { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_low_quote: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 27 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 27 | my %enquote = ("\012" => 'n', "\015" => 'r', "\0" => '0', "\cP" => "\cP"); | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 27 | ▶ | if (!defined $line) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | croak 'Not enough arguments to POE::Filter::IRC::Compat->_low_quote'; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 27 | ▶ | if ($line =~ tr/[\012\015\0\cP]//) { # quote \n, \r, ^P, and \0. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $line =~ s/([\012\015\0\cP])/\cP$enquote{$1}/g; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 27 | return $line; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | # Does low-level dequoting on CTCP messages. I hate this protocol. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # Yes, I copied this whole section out of Net::IRC. | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 34 | ▶ | sub _low_dequote { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_low_dequote: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 34 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 34 | my %dequote = (n => "\012", r => "\015", 0 => "\0", "\cP" => "\cP"); | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 34 | ▶ | if (!defined $line) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | croak 'Not enough arguments to POE::Filter::IRC::Compat->_low_dequote'; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | # dequote \n, \r, ^P, and \0. | ||||||||||||||||||||||||||||||||||||||||||
| 425 | # Thanks to Abigail (abigail@foad.org) for this clever bit. | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 34 | ▶ | if ($line =~ tr/\cP//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $line =~ s/\cP([nr0\cP])/$dequote{$1}/g; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 34 | return $line; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 80 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | POE::Filter::IRC::Compat - A filter which converts L<POE::Filter::IRCD|POE::Filter::IRCD> | ||||||||||||||||||||||||||||||||||||||||||
| 440 | output into L<POE::Component::IRC|POE::Component::IRC> events | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | my $filter = POE::Filter::IRC::Compat->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 445 | my @events = @{ $filter->get( [ @lines ] ) }; | ||||||||||||||||||||||||||||||||||||||||||
| 446 | my @msgs = @{ $filter->put( [ @messages ] ) }; | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | POE::Filter::IRC::Compat is a L<POE::Filter|POE::Filter> that converts | ||||||||||||||||||||||||||||||||||||||||||
| 451 | L<POE::Filter::IRCD|POE::Filter::IRCD> output into the L<POE::Component::IRC|POE::Component::IRC> | ||||||||||||||||||||||||||||||||||||||||||
| 452 | compatible event references. Basically a hack, so I could replace | ||||||||||||||||||||||||||||||||||||||||||
| 453 | L<POE::Filter::IRC|POE::Filter::IRC> with something that was more | ||||||||||||||||||||||||||||||||||||||||||
| 454 | generic. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | Among other things, it converts normal text into thoroughly CTCP-quoted | ||||||||||||||||||||||||||||||||||||||||||
| 457 | messages, and transmogrifies CTCP-quoted messages into their normal, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | sane components. Rather what you'd expect a filter to do. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | A note: the CTCP protocol sucks bollocks. If I ever meet the fellow who | ||||||||||||||||||||||||||||||||||||||||||
| 461 | came up with it, I'll shave their head and tattoo obscenities on it. | ||||||||||||||||||||||||||||||||||||||||||
| 462 | Just read the "specification" (F<docs/ctcpspec.html> in this distribution) | ||||||||||||||||||||||||||||||||||||||||||
| 463 | and you'll hopefully see what I mean. Quote this, quote that, quote this | ||||||||||||||||||||||||||||||||||||||||||
| 464 | again, all in different and weird ways... and who the hell needs to send | ||||||||||||||||||||||||||||||||||||||||||
| 465 | mixed CTCP and text messages? WTF? It looks like it's practically complexity | ||||||||||||||||||||||||||||||||||||||||||
| 466 | for complexity's sake -- and don't even get me started on the design of the | ||||||||||||||||||||||||||||||||||||||||||
| 467 | DCC protocol! Anyhow, enough ranting. Onto the rest of the docs... | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | =head2 C<new> | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | Returns a POE::Filter::IRC::Compat object. Takes no arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | =head2 C<clone> | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | Makes a copy of the filter, and clears the copy's buffer. | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | =head2 C<get> | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | Takes an arrayref of L<POE::Filter::IRCD> hashrefs and produces an arrayref of | ||||||||||||||||||||||||||||||||||||||||||
| 482 | L<POE::Component::IRC|POE::Component::IRC> compatible event hashrefs. Yay. | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | =head2 C<get_one_start>, C<get_one> | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | These perform a similar function as C<get> but enable the filter to work with | ||||||||||||||||||||||||||||||||||||||||||
| 487 | L<POE::Filter::Stackable|POE::Filter::Stackable>. | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | =head2 C<put> | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | Takes an array reference of CTCP messages to be properly quoted. This | ||||||||||||||||||||||||||||||||||||||||||
| 492 | doesn't support CTCPs embedded in normal messages, which is a | ||||||||||||||||||||||||||||||||||||||||||
| 493 | brain-dead hack in the protocol, so do it yourself if you really need | ||||||||||||||||||||||||||||||||||||||||||
| 494 | it. Returns an array reference of the quoted lines for sending. | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | =head2 C<debug> | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | Takes an optinal true/false value which enables/disables debugging | ||||||||||||||||||||||||||||||||||||||||||
| 499 | accordingly. Returns the debug status. | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | =head2 C<chantypes> | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | Takes an arrayref of possible channel prefix indicators. | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | =head2 C<identifymsg> | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | Takes a boolean to turn on/off the support for CAPAB IDENTIFY-MSG. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | Chris 'BinGOs' Williams | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | L<POE::Filter::IRCD|POE::Filter::IRCD> | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | L<POE::Filter|POE::Filter> | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | L<POE::Filter::Stackable|POE::Filter::Stackable> | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | =cut | ||||||||||||||||||||||||||||||||||||||||||