line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IRC::Toolkit::Parser; |
2
|
|
|
|
|
|
|
$IRC::Toolkit::Parser::VERSION = '0.092002'; |
3
|
2
|
|
|
2
|
|
452
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
101
|
|
4
|
2
|
|
|
2
|
|
399
|
use strictures 2; |
|
2
|
|
|
|
|
1096
|
|
|
2
|
|
|
|
|
66
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
609
|
use parent 'Exporter::Tiny'; |
|
2
|
|
|
|
|
211
|
|
|
2
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw/ |
8
|
|
|
|
|
|
|
irc_ref_from_line |
9
|
|
|
|
|
|
|
irc_line_from_ref |
10
|
|
|
|
|
|
|
/; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
2599
|
use Scalar::Util 'blessed', 'reftype'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
102
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
401
|
use POE::Filter::IRCv3; |
|
2
|
|
|
|
|
1921
|
|
|
2
|
|
|
|
|
231
|
|
15
|
|
|
|
|
|
|
my $filter = 'POE::Filter::IRCv3'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub irc_ref_from_line { |
18
|
1
|
|
|
1
|
1
|
721
|
my $line = shift; |
19
|
1
|
50
|
|
|
|
3
|
confess "Expected a line and optional filter arguments" |
20
|
|
|
|
|
|
|
unless $line; |
21
|
1
|
|
|
|
|
7
|
$filter->new(@_)->get([$line])->[0] |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub irc_line_from_ref { |
25
|
2
|
|
|
2
|
1
|
1098
|
my $ref = shift; |
26
|
2
|
50
|
|
|
|
8
|
confess "Expected a HASH and optional filter arguments" |
27
|
|
|
|
|
|
|
unless reftype $ref eq 'HASH'; |
28
|
2
|
100
|
|
|
|
8
|
$filter->new(@_)->put([blessed $ref ? +{%$ref} : $ref])->[0] |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
IRC::Toolkit::Parser - Functional-style IRC filter interface |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use IRC::Toolkit::Parser; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $raw_irc_line = ':avenj PRIVMSG #channel :things'; |
42
|
|
|
|
|
|
|
my $ref = irc_ref_from_line( $raw_irc_line ); |
43
|
|
|
|
|
|
|
my $raw_line = irc_line_from_ref( $ref, colonify => 1 ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A simple functional-style frontend to L. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This will be slower than using the filter directly, but it's convenient for |
50
|
|
|
|
|
|
|
one-offs. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
See L for details. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Also see L for a handy object-oriented interface to IRC |
55
|
|
|
|
|
|
|
event transformation. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 irc_ref_from_line |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Takes a raw IRC line and returns a HASH as described in the documentation for |
60
|
|
|
|
|
|
|
L. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 irc_line_from_ref |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Takes a HASH as described in L and returns a raw IRC line. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Jon Portnoy |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |