| 1 | package POE::Filter::IRCv3; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $POE::Filter::IRCv3::VERSION = '1.002002'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Not mandatory, but handy for POE apps, in which case POE is presumably | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # installed already; we can do all POE::Filter-y things, this only matters for | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # ->isa('POE::Filter') -> | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | if (eval { require POE::Filter; 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our @ISA = 'POE::Filter'; | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =for Pod::Coverage COLONIFY DEBUG BUFFER SPCHR | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub COLONIFY () { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub DEBUG () { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub BUFFER () { 2 } | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub SPCHR () { "\x20" } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | our %CharToEscapedTag = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | ';' => '\:', | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ' ' => '\s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | "\\" => '\\', | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | "\r" => '\r', | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | "\n" => '\n', | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | "\a" => '\a', | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | our %EscapedTagToChar = reverse %CharToEscapedTag; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=17.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my ($class, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | $params{uc $_} = $params{$_} for keys %params; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | bless [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ($params{'COLONIFY'} || 0), | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | ($params{'DEBUG'} || $ENV{POE_FILTER_IRC_DEBUG} || 0), | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition57%4/7
$params{'COLONIFY'} || 0
$params{'DEBUG'} || $ENV{'POE_FILTER_IRC_DEBUG'} || 0
$params{"DEBUG"} or $ENV{"POE_FILTER_IRC_DEBUG"}
MC/DC100%1/1
$params{'COLONIFY'} || 0
$params{'COLONIFY'}
MC/DC0%0/2
$params{'DEBUG'} || $ENV{'POE_FILTER_IRC_DEBUG'} || 0
$params{"DEBUG"}
$ENV{"POE_FILTER_IRC_DEBUG"}
Truth table100%2/2
A
A= $params{'COLONIFY'}
Truth table33%1/3
A or B
A= $params{"DEBUG"}B= $ENV{"POE_FILTER_IRC_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | [] # BUFFER | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ], $class | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my $nself = [@$self]; | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $nself->[BUFFER] = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | bless $nself, ref $self | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | sub debug { defined $_[1] ? $_[0]->[DEBUG] = $_[1] : $_[0]->[DEBUG] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | sub colonify { defined $_[1] ? $_[0]->[COLONIFY] = $_[1] : $_[0]->[COLONIFY] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colonify: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | sub get_one_start { push @{ $_[0]->[BUFFER] }, $_ for @{ $_[1] }; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_one_start: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub get_pending { @{ $_[0]->[BUFFER] } ? [ @{ $_[0]->[BUFFER] } ] : () } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_pending: called CC=2 SCAR=7.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 39 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 39 | my @events; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | for my $raw_line (@{ $_[1] }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 39 | ▶ | warn " >> '$raw_line'\n" if $_[0]->[DEBUG]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 39 | ▶ | if ( my $event = parse_one_line($raw_line) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 36 | push @events, $event; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # carp here because caller provided lines: | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | carp "Received malformed IRC input: $raw_line"; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | \@events | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 39 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | sub get_one { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_one: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my @events; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | if ( my $raw_line = shift @{ $self->[BUFFER] } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | warn " >> '$raw_line'\n" if $self->[DEBUG]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | if ( my $event = parse_one_line($raw_line) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | push @events, $event; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # ..but warn here because who knows where the buffer came from: | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | warn "Received malformed IRC input: $raw_line\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | \@events | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | no warnings 'substr'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 21 | ▶ | sub put { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: called CC=20 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 21 | my ($self, $events) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 21 | my $raw_lines = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 21 | for my $event (@$events) { | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 21 | ▶ | if ( ref $event eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 21 | my $raw_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ## FIXME this gets glacially slow -> | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # y// over string for escapes first and then loop? | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 21 | ▶ | if ( exists $event->{tags} && (my @tags = %{ $event->{tags} }) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $event->{"tags"} and my(@tags) = %{$event->{"tags"};}
MC/DC50%1/2
exists $event->{"tags"} and my(@tags) = %{$event->{"tags"};}
exists $event->{"tags"}
my(@tags) = %{$event->{"tags"};}
Truth table66%2/3
A and B
A= exists $event->{"tags"}B= my(@tags) = %{$event->{"tags"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | $raw_line .= '@'; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | while (my ($thistag, $thisval) = splice @tags, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | $raw_line .= $thistag; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | ▶ | if (defined $thisval) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | $raw_line .= '='; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 6 | my $tag_pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | my $len = length $thisval; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | ▶ | while ($tag_pos < $len) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 39 | my $ch = substr $thisval, $tag_pos++, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | $raw_line .= exists $CharToEscapedTag{$ch} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 39 | ▶ | $CharToEscapedTag{$ch} : $ch | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | ▶ | $raw_line .= ';' if @tags; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | $raw_line .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 21 | ▶ | $raw_line .= ':' . $event->{prefix} . ' ' if $event->{prefix}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 21 | $raw_line .= $event->{command}; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 21 | ▶ | if ( $event->{params} && (my @params = @{ $event->{params} }) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$event->{"params"} and my(@params) = @{$event->{"params"};}
MC/DC50%1/2
$event->{"params"} and my(@params) = @{$event->{"params"};}
$event->{"params"}
my(@params) = @{$event->{"params"};}
Truth table66%2/3
A and B
A= $event->{"params"}B= my(@params) = @{$event->{"params"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 17 | $raw_line .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 17 | my $param = shift @params; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 17 | ▶ | while (@params) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 14 | $raw_line .= $param . ' '; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 14 | $param = shift @params; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $raw_line .= ':' | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | if (index($param, SPCHR) != -1) | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | or (index($param, ':') == 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | or ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | defined $event->{colonify} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 17 | ▶ | $event->{colonify} : $self->[COLONIFY] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
(index($param, " ") != -1) or index($param, ":") == 0 or defined $event->{"colonify"} ? $event->{"colonify"} : $self->[0]
(index($param, " ") != -1) or index($param, ":") == 0
MC/DC66%2/3
(index($param, " ") != -1) or index($param, ":") == 0 or defined $event->{"colonify"} ? $event->{"colonify"} : $self->[0]
(index($param, " ") != -1)
index($param, ":") == 0
defined $event->{"colonify"} ? $event->{"colonify"} : $self->[0]
Truth table75%3/4
A or B or C
A= (index($param, " ") != -1)B= index($param, ":") == 0C= defined $event->{"colonify"} ? $event->{"colonify"} : $self->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 17 | $raw_line .= $param; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 21 | push @$raw_lines, $raw_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 21 | ▶ | warn " << '$raw_line'\n" if $self->[DEBUG]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | carp "($self) non-HASH passed to put(): '$event'"; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | push @$raw_lines, $event if ref $event eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $raw_lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 42 | ▶ | sub parse_one_line { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_one_line: called CC=21 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 42 | my $raw_line = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 42 | my %event = ( raw_line => $raw_line ); | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 42 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ## We cheat a little; the spec is fuzzy when it comes to CR, LF, and NUL | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ## bytes. Theoretically they're not allowed inside messages, but | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ## that's really an implementation detail (and the spec agrees). | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ## We just stick to SPCHR (\x20) here. | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 42 | ▶ | if ( substr($raw_line, 0, 1) eq '@' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 21 | ▶ | return unless (my $nextsp = index($raw_line, SPCHR)) > 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Tag parser cheats and uses split, at the moment: | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 21 | for ( split /;/, substr $raw_line, 1, ($nextsp - 1) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 41 | my ($thistag, $thisval) = split /=/; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 41 | my $realval; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 41 | ▶ | if (defined $thisval) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 28 | my $tag_pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 28 | my $len = length $thisval; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 28 | ▶ | while ($tag_pos < $len) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 130 | my $ch = substr $thisval, $tag_pos++, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 130 | ▶ | if ($ch eq "\\") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 12 | ▶ | my $pair = $ch . (substr($thisval, $tag_pos++, 1) || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
substr($thisval, $tag_pos++, 1) || ''
MC/DC0%0/1
substr($thisval, $tag_pos++, 1) || ''
substr($thisval, $tag_pos++, 1)
Truth table50%1/2
A
A= substr($thisval, $tag_pos++, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $realval .= exists $EscapedTagToChar{$pair} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 12 | ▶ | $EscapedTagToChar{$pair} : substr $pair, 1, 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 118 | $realval .= $ch | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 41 | $event{tags}->{$thistag} = $realval | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 21 | $pos = $nextsp + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 42 | ▶ | $pos++ while substr($raw_line, $pos, 1) eq SPCHR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 42 | ▶ | if ( substr($raw_line, $pos, 1) eq ':' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 26 | my $nextsp; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | ($nextsp = index $raw_line, SPCHR, $pos) > 0 and length( | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 26 | ▶ | $event{prefix} = substr $raw_line, ($pos + 1), ($nextsp - $pos - 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
($nextsp = index($raw_line, " ", $pos)) > 0 and length($event{"prefix"} = substr($raw_line, $pos + 1, $nextsp - $pos - 1))
MC/DC100%2/2
($nextsp = index($raw_line, " ", $pos)) > 0 and length($event{"prefix"} = substr($raw_line, $pos + 1, $nextsp - $pos - 1))
($nextsp = index($raw_line, " ", $pos)) > 0
length($event{"prefix"} = substr($raw_line, $pos + 1, $nextsp - $pos - 1))
Truth table100%3/3
A and B
A= ($nextsp = index($raw_line, " ", $pos)) > 0B= length($event{"prefix"} = substr($raw_line, $pos + 1, $nextsp - $pos - 1))
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 23 | $pos = $nextsp + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 23 | ▶ | $pos++ while substr($raw_line, $pos, 1) eq SPCHR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 39 | my $nextsp_maybe; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 39 | ▶ | if ( ($nextsp_maybe = index $raw_line, SPCHR, $pos) == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # No more spaces; do we have anything..? | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 8 | my $cmd = substr $raw_line, $pos; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | ▶ | $event{command} = uc( length $cmd ? $cmd : return ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 8 | return \%event | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $event{command} = uc( | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 31 | substr($raw_line, $pos, ($nextsp_maybe - $pos) ) | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 31 | $pos = $nextsp_maybe + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 31 | ▶ | $pos++ while substr($raw_line, $pos, 1) eq SPCHR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 31 | my $maxlen = length $raw_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 31 | ▶ | PARAM: while ( $pos < $maxlen ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 54 | ▶ | if ( substr($raw_line, $pos, 1) eq ':' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 21 | push @{ $event{params} }, substr $raw_line, ($pos + 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | last PARAM | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 33 | ▶ | if ( (my $nextsp = index $raw_line, SPCHR, $pos) == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 9 | push @{ $event{params} }, substr $raw_line, $pos; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | last PARAM | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 9 | } else { | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 24 | push @{ $event{params} }, substr $raw_line, $pos, ($nextsp - $pos); | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 24 | $pos = $nextsp + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 24 | ▶ | $pos++ while substr($raw_line, $pos, 1) eq SPCHR; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | next PARAM | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 24 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 31 | \%event | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | no bytes; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | |||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | qq[<mst> let's try this again -without- the part where we beat you to], | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | qq[ death with a six foot plush toy of sexual harassment panda\n ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | unless caller; 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | POE::Filter::IRCv3 - Fast IRCv3.2 parser for POE or stand-alone use | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | my $filter = POE::Filter::IRCv3->new(colonify => 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # Raw lines parsed to hashes: | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | my $array_of_refs = $filter->get( | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ':prefix COMMAND foo :bar', | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | '@foo=bar;baz :prefix COMMAND foo :bar', | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # Hashes deparsed to raw lines: | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | my $array_of_lines = $filter->put( | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | prefix => 'prefix', | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | command => 'COMMAND', | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | params => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 'foo', | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 'bar' | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | prefix => 'prefix', | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | command => 'COMMAND', | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | params => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 'foo', | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 'bar' | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | tags => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | foo => 'bar', | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | baz => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # Stacked with a line filter, suitable for Wheel usage, etc: | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | my $ircd = POE::Filter::IRCv3->new(colonify => 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | my $line = POE::Filter::Line->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | InputRegexp => '\015?\012', | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | OutputLiteral => "\015\012", | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | my $stacked = POE::Filter::Stackable->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | Filters => [ $line, $ircd ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Functional parser interface: | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | my $event = POE::Filter::IRCv3::parse_one_line( | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ':foo PRIVMSG #bar :baz quux' | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | A L<POE::Filter> for IRC traffic with support for IRCv3.2 message tags. | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | Does not rely on regular expressions for parsing. Benchmarks show this | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | approach is generally faster on the most common IRC strings. | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | Like any proper L<POE::Filter>, there are no POE-specific bits involved here | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | -- the filter can be used stand-alone to parse lines of IRC traffic (also see | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | L<IRC::Toolkit::Parser>). | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | In fact, you do not need L<POE> installed -- if L<POE::Filter> is not | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | available, it is left out of C<@ISA> and the filter will continue working | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | normally. | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | =head2 POE / Object interface | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | =head3 new | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | Construct a new Filter; if the B<colonify> option is true, | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | the last parameter will always have a colon prepended. | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | (This setting can also be retrieved or changed on-the-fly by calling | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | B<colonify> as a method, or changed for specific events by passing a | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | B<colonify> option via events passed to L</put>.) | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | =head3 get_one_start, get_one, get_pending | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | Implement the interface described in L<POE::Filter>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | See L</get>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =head3 get | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | my $events = $filter->get( [ $line, $another, ... ] ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | for my $event (@$events) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | my $cmd = $event->{command}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ## See below for other keys available | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Takes an ARRAY of raw lines and returns an ARRAY of HASH-type references with | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | the following keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | =head4 command | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | The (uppercased) command or numeric. | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | =head4 params | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | An ARRAY containing the event parameters. | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | =head4 prefix | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | The sender prefix, if any. | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | =head4 tags | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | A HASH of key => value pairs matching IRCv3.2 "message tags" -- see | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | L<http://ircv3.atheme.org>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | Note that a tag can be present, but have an undefined value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =head3 put | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | my $lines = $filter->put( [ $hash, $another_hash, ... ] ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | for my $line (@$lines) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ## Direct to socket, etc | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Takes an ARRAY of HASH-type references matching those described in L</get> | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | (documented above) and returns an ARRAY of raw IRC-formatted lines. | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | =head4 colonify | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | In addition to the keys described in L</get>, the B<colonify> option can be | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | specified for specific events. This controls whether or not the last | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | parameter will be colon-prefixed even if it is a single word. (Yes, IRC is | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | woefully inconsistent ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | Specify as part of the event hash: | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | $filter->put([ { %event, colonify => 1 } ]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =head3 clone | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | Copy the filter object (with a cleared buffer). | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | =head3 debug | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | Turn on/off debug output, which will display every input/output line (and | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | possibly other data in the future). | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | This is enabled by default at construction time if the environment variable | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | C<POE_FILTER_IRC_DEBUG> is a true value. | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | =head2 Functional interface | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | =head3 parse_one_line | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | If the filter is being used as a stand-alone IRC parser and speed is of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | essence, you can skip method resolution & queue handling by calling the parse | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | function directly using the fully-qualified name: | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | my $ev = POE::Filter::IRCv3::parse_one_line( $line ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | The function takes a single line and returns a HASH whose structure is | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | described in the documentation for L</get>, above. | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | If the given line cannot be parsed, the function returns false (rather than | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | throwing an exception, as L</get> would). | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | There is currently no functional interface to message string composition | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | (L</put>). | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | Licensed under the same terms as Perl. | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | Original implementations were derived from L<POE::Filter::IRCD>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | which is copyright Chris Williams and Jonathan Steinert. This codebase has | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | diverged significantly. | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | Major thanks to the C<#ircv3> crew on irc.atheme.org, especially C<Aerdan> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | C<grawity>, for various bits of inspiration. | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | L<IRC::Message::Object> | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | L<POE::Filter> | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | L<POE::Filter::IRCD> | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | L<POE::Filter::Line> | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | L<POE::Filter::Stackable> | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | L<IRC::Toolkit> | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||