line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Bot::IRC::Message; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
130841
|
use warnings; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
67
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
45
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1058
|
use Params::Validate; |
|
2
|
|
|
|
|
17905
|
|
|
2
|
|
|
|
|
117
|
|
7
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
729
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Bot::IRC::Message - An IRC protocol message class. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.0.1 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.0.1'; |
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
|
371
|
my $class = shift; |
50
|
2
|
|
|
|
|
68
|
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
|
|
|
|
|
14
|
bless $self, $class; |
71
|
2
|
|
|
|
|
14
|
return $self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 parse() |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub parse { |
79
|
1
|
|
|
1
|
1
|
3
|
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
|
|
|
|
10
|
if ($message =~ /:(\S+) (\d\d\d) (.+)/) { |
87
|
1
|
|
|
|
|
3
|
$self->{prefix} = $1; |
88
|
1
|
|
|
|
|
4
|
$self->{command} = $2; |
89
|
1
|
|
|
|
|
4
|
$self->{params} = $3; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return ($self->{prefix}, |
93
|
|
|
|
|
|
|
$self->{command}, |
94
|
1
|
|
|
|
|
5
|
$self->{params}); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 compile() |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub compile { |
102
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
1
|
50
|
33
|
|
|
12
|
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
|
|
|
|
|
|
|
my $message = ":" . $self->{prefix} . " " |
111
|
|
|
|
|
|
|
. $self->{command} . " " |
112
|
1
|
|
|
|
|
6
|
. $self->{params}; |
113
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
3
|
$self->{unparsed} = $message; |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
2
|
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 2023 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 |