| 1 | package Net::Bot::IRC::Message; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Params::Validate; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | 3 | 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 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | 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 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =head2 parse() | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | sub parse { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | unless (exists $self->{unparsed}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | croak "No message to parse."; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my $message = $self->{unparsed}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | if ($message =~ /:(\S+) (\d\d\d) (.+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $self->{prefix} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | $self->{command} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $self->{params} = $3; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | return ($self->{prefix}, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | $self->{command}, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $self->{params}); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =head2 compile() | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | sub compile { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | unless ( exists $self->{prefix} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $self->{"prefix"} and exists $self->{"command"} and exists $self->{"params"}
exists $self->{"prefix"} and exists $self->{"command"}
MC/DC0%0/3
exists $self->{"prefix"} and exists $self->{"command"} and exists $self->{"params"}
exists $self->{"prefix"}
exists $self->{"command"}
exists $self->{"params"}
Truth table25%1/4
A and B and C
A= exists $self->{"prefix"}B= exists $self->{"command"}C= exists $self->{"params"}
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | && exists $self->{command} | ||||||||||||||||||||||||||||||||||||||||||
| 106 | && exists $self->{params}) { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | croak "Prefix, command and params not specified."; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | my $message = ":" . $self->{prefix} . " " | ||||||||||||||||||||||||||||||||||||||||||
| 111 | . $self->{command} . " " | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | . $self->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | $self->{unparsed} = $message; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | return $self->{unparsed}; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | Mark Caudill, C<< <mcaudill at cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | =head1 SOURCE | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | The source for this module is maintained at C<< <git@github.com:flakblas/Net-Bot-IRC-Message.git> >>. | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | Please report any bugs or feature requests to C<bug-net-bot-irc-message at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||||||
| 130 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Bot-IRC-Message>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Bot-IRC-Message> | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | L<http://annocpan.org/dist/Net-Bot-IRC-Message> | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | L<http://cpanratings.perl.org/d/Net-Bot-IRC-Message> | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | L<http://search.cpan.org/dist/Net-Bot-IRC-Message/> | ||||||||||||||||||||||||||||||||||||||||||
| 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 | 3 | 1; # End of Net::Bot::IRC::Message | |||||||||||||||||||||||||||||||||||||||||