| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Bot::IRC::Message; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
51738
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
67
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
103
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2085
|
use Params::Validate; |
|
|
2
|
|
|
|
|
23149
|
|
|
|
2
|
|
|
|
|
130
|
|
|
7
|
2
|
|
|
2
|
|
19
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
811
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Bot::IRC::Message - An IRC protocol message class. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Net::Bot::IRC::Message; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $outgoing = Net::Bot::IRC::Message->new({ |
|
27
|
|
|
|
|
|
|
prefix => $prefix, #Optional |
|
28
|
|
|
|
|
|
|
command => $cmd, |
|
29
|
|
|
|
|
|
|
params => $params, |
|
30
|
|
|
|
|
|
|
}); |
|
31
|
|
|
|
|
|
|
my $raw_message = $outgoing->compile(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $incoming = Net::Bot::IRC::Message->new({ |
|
34
|
|
|
|
|
|
|
unparsed => $raw_message, |
|
35
|
|
|
|
|
|
|
}); |
|
36
|
|
|
|
|
|
|
my ($prefix, $command, $params) |
|
37
|
|
|
|
|
|
|
= $incoming->parse(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new( prefix => $prefix, command => $cmd, params => $params ) |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new( unparsed => $raw_message ) |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
|
49
|
2
|
|
|
2
|
1
|
444
|
my $class = shift; |
|
50
|
2
|
|
|
|
|
2939
|
my $self = validate(@_, { |
|
51
|
|
|
|
|
|
|
# For outgoing messages. |
|
52
|
|
|
|
|
|
|
prefix => { |
|
53
|
|
|
|
|
|
|
optional => 1, |
|
54
|
|
|
|
|
|
|
depends => [ 'command', 'params' ], |
|
55
|
|
|
|
|
|
|
}, |
|
56
|
|
|
|
|
|
|
command => { |
|
57
|
|
|
|
|
|
|
optional => 1, |
|
58
|
|
|
|
|
|
|
depends => [ 'params' ], |
|
59
|
|
|
|
|
|
|
}, |
|
60
|
|
|
|
|
|
|
params => { |
|
61
|
|
|
|
|
|
|
optional => 1, |
|
62
|
|
|
|
|
|
|
depends => [ 'command' ], |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
|
|
|
|
|
|
# For incoming messages |
|
65
|
|
|
|
|
|
|
unparsed => { |
|
66
|
|
|
|
|
|
|
optional => 1, |
|
67
|
|
|
|
|
|
|
}, |
|
68
|
|
|
|
|
|
|
}); |
|
69
|
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
17
|
bless $self, $class; |
|
71
|
2
|
|
|
|
|
12
|
return $self; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 parse() |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub parse { |
|
79
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
80
|
1
|
50
|
|
|
|
5
|
unless (exists $self->{unparsed}) { |
|
81
|
0
|
|
|
|
|
0
|
croak "No message to parse."; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
2
|
my $message = $self->{unparsed}; |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
50
|
|
|
|
7
|
if ($message =~ /:(\S+) (\d\d\d) (.+)/) { |
|
87
|
1
|
|
|
|
|
4
|
$self->{prefix} = $1; |
|
88
|
1
|
|
|
|
|
3
|
$self->{command} = $2; |
|
89
|
1
|
|
|
|
|
6
|
$self->{params} = $3; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
9
|
return ($self->{prefix}, |
|
93
|
|
|
|
|
|
|
$self->{command}, |
|
94
|
|
|
|
|
|
|
$self->{params}); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 compile() |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub compile { |
|
102
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
50
|
33
|
|
|
15
|
unless ( exists $self->{prefix} |
|
|
|
|
33
|
|
|
|
|
|
105
|
|
|
|
|
|
|
&& exists $self->{command} |
|
106
|
|
|
|
|
|
|
&& exists $self->{params}) { |
|
107
|
0
|
|
|
|
|
0
|
croak "Prefix, command and params not specified."; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
5
|
my $message = ":" . $self->{prefix} . " " |
|
111
|
|
|
|
|
|
|
. $self->{command} . " " |
|
112
|
|
|
|
|
|
|
. $self->{params}; |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
3
|
$self->{unparsed} = $message; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
3
|
return $self->{unparsed}; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Mark Caudill, C<< >> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SOURCE |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The source for this module is maintained at C<< >>. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 BUGS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
130
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
131
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SUPPORT |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
perldoc Net::Bot::IRC::Message |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
You can also look for information at: |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * Search CPAN |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2010 Mark Caudill. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
167
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
168
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; # End of Net::Bot::IRC::Message |