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