| 1 | package POE::Component::IRC::Plugin::ISupport; | ||||||||||||||||||||||||||||
| 2 | 79 | our $AUTHORITY = 'cpan:HINRIK'; | |||||||||||||||||||||||||||
| 3 | 79 | $POE::Component::IRC::Plugin::ISupport::VERSION = '6.92'; | |||||||||||||||||||||||||||
| 4 | 79 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 79 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 79 | ▶ | use POE::Component::IRC::Plugin qw(:ALL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||||||||||
| 9 | 0 | ▶ | return bless { }, shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub PCI_register { | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my ($self, $irc) = splice @_, 0, 2; | ||||||||||||||||||||||||||
|
Subroutine
PCI_register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | $irc->plugin_register( $self => SERVER => qw(all) ); | |||||||||||||||||||||||||||
| 16 | 0 | $self->{irc} = $irc; | |||||||||||||||||||||||||||
| 17 | $self->{parser} = { | ||||||||||||||||||||||||||||
| 18 | CASEMAPPING => sub { | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 20 | 0 | $support->{$key} = $val; | |||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | CHANLIMIT => sub { | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | while ($val =~ /([^:]+):(\d+),?/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($k, $v) = ($1, $2); | |||||||||||||||||||||||||||
| 26 | 0 | @{ $support->{$key} }{ split(//, $k) } = ($v) x length $k; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||||||||||
| 29 | CHANMODES => sub { | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 31 | 0 | $support->{$key} = [ split(/,/, $val) ]; | |||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | CHANTYPES => sub { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 35 | 0 | $support->{$key} = [ split(//, $val) ]; | |||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||
| 37 | ELIST => sub { | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 39 | 0 | $support->{$key} = [ split(//, $val) ]; | |||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | IDCHAN => sub { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | while ($val =~ /([^:]+):(\d+),?/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | my ($k, $v) = ($1, $2); | |||||||||||||||||||||||||||
| 45 | 0 | @{ $support->{$key} }{ split(//, $k) } = ($v) x length $k; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||
| 48 | MAXLIST => sub { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | while ($val =~ /([^:]+):(\d+),?/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | my ($k, $v) = ($1, $2); | |||||||||||||||||||||||||||
| 52 | 0 | @{ $support->{$key} }{ split(//, $k) } = ($v) x length $k; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||
| 55 | PREFIX => sub { | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (my ($k, $v) = $val =~ /\(([^)]+)\)(.*)/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | @{ $support->{$key} }{ split(//, $k) } = split(//, $v); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||
| 61 | STATUSMSG => sub { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 63 | 0 | $support->{$key} = [ split(//, $val) ]; | |||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||
| 65 | TARGMAX => sub { | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my ($support, $key, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | while ($val =~ /([^:]+):(\d*),?/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | my ($k, $v) = ($1, $2); | |||||||||||||||||||||||||||
| 69 | 0 | $support->{$key}->{$k} = $v; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | }, | ||||||||||||||||||||||||||||
| 72 | EXCEPTS => sub { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my ($support, $flag) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 74 | 0 | $support->{$flag} = 'e'; | |||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||
| 76 | INVEX => sub { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($support, $flag) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 78 | 0 | $support->{$flag} = 'I'; | |||||||||||||||||||||||||||
| 79 | }, | ||||||||||||||||||||||||||||
| 80 | 0 | }; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | return 1; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub PCI_unregister { | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my ($self, $irc) = splice @_, 0, 2; | ||||||||||||||||||||||||||
|
Subroutine
PCI_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 0 | delete $self->{irc}; | |||||||||||||||||||||||||||
| 88 | 0 | return 1; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub S_connected { | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my ($self, $irc) = splice @_, 0, 2; | ||||||||||||||||||||||||||
|
Subroutine
S_connected: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | $self->{server} = { }; | |||||||||||||||||||||||||||
| 95 | 0 | $self->{got_005} = 0; | |||||||||||||||||||||||||||
| 96 | 0 | $self->{done_005} = 0; | |||||||||||||||||||||||||||
| 97 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | sub S_005 { | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my ($self, $irc, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
S_005: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 0 | my @vals = @{ ${ $args[2] } }; | |||||||||||||||||||||||||||
| 103 | 0 | pop @vals; | |||||||||||||||||||||||||||
| 104 | 0 | my $support = $self->{server}; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | for my $val (@vals) { | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($val =~ /=/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 0 | my $key; | |||||||||||||||||||||||||||
| 109 | 0 | ($key, $val) = split(/=/, $val, 2); | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (defined $self->{parser}->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | $self->{parser}->{$key}->($support, $key, $val); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | else { | ||||||||||||||||||||||||||||
| 114 | # AWAYLEN CHANNELLEN CHIDLEN CHARSET EXCEPTS INVEX KICKLEN | ||||||||||||||||||||||||||||
| 115 | # MAXBANS MAXCHANNELS MAXTARGETS MODES NETWORK NICKLEN STD | ||||||||||||||||||||||||||||
| 116 | # TOPICLEN WATCH | ||||||||||||||||||||||||||||
| 117 | 0 | $support->{$key} = $val; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if (defined $self->{parser}->{$val}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | $self->{parser}->{$val}->($support, $val); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||||
| 125 | # ACCEPT CALLERID CAPAB CNOTICE CPRIVMSG FNC KNOCK MAXNICKLEN | ||||||||||||||||||||||||||||
| 126 | # NAMESX NOQUIT PENALTY RFC2812 SAFELIST UHNAMES USERIP | ||||||||||||||||||||||||||||
| 127 | # VCHANS WALLCHOPS WALLVOICES WHOX | ||||||||||||||||||||||||||||
| 128 | 0 | $support->{$val} = 'on'; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | $self->{got_005}++; | |||||||||||||||||||||||||||
| 134 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | sub _default { | ||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my ($self, $irc, $event) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_default: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return PCI_EAT_NONE if $self->{done_005}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return PCI_EAT_NONE if !$self->{got_005}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ($event =~ /^S_(\d+)/ and $1 > 5) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$event =~ /^S_(\d+)/ and $1 > 5
MC/DC0%0/2
$event =~ /^S_(\d+)/ and $1 > 5
$event =~ /^S_(\d+)/
$1 > 5
Truth table0%0/3
A and B
A= $event =~ /^S_(\d+)/B= $1 > 5
| |||||||||||||||||||||||||||||
| 144 | 0 | $self->{done_005} = 1; | |||||||||||||||||||||||||||
| 145 | 0 | $irc->send_event_now(irc_isupport => $self); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | sub isupport { | ||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
isupport: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $value = uc ( $_[0] ) || return; | ||||||||||||||||||||||||||
|
Condition0%0/2
uc $_[0] || (return)
MC/DC0%0/1
uc $_[0] || (return)
uc $_[0]
Truth table0%0/2
A
A= uc $_[0]
| |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return $self->{server}->{$value} if defined $self->{server}->{$value}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | return; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub isupport_dump_keys { | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
isupport_dump_keys: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( keys %{ $self->{server} } > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | return keys %{ $self->{server} }; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 0 | return; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 79 | 1; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =encoding utf8 | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =head1 NAME | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | POE::Component::IRC::Plugin::ISupport - A PoCo-IRC plugin that handles server | ||||||||||||||||||||||||||||
| 175 | capabilities | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | This handles the C<irc_005> messages that come from the server. They | ||||||||||||||||||||||||||||
| 180 | define the capabilities support by the server. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | =head1 METHODS | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =head2 C<new> | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Takes no arguments. | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | Returns a plugin object suitable for feeding to | ||||||||||||||||||||||||||||
| 189 | L<POE::Component::IRC|POE::Component::IRC>'s C<plugin_add> method. | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =head2 C<isupport> | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Takes one argument. the server capability to query. Returns a false value on | ||||||||||||||||||||||||||||
| 194 | failure or a value representing the applicable capability. A full list of | ||||||||||||||||||||||||||||
| 195 | capabilities is available at L<http://www.irc.org/tech_docs/005.html>. | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =head2 C<isupport_dump_keys> | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | Takes no arguments, returns a list of the available server capabilities, | ||||||||||||||||||||||||||||
| 200 | which can be used with C<isupport>. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =head1 INPUT | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | This module handles the following PoCo-IRC signals: | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =head2 C<irc_005> (RPL_ISUPPORT or RPL_PROTOCTL) | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | Denotes the capabilities of the server. | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =head2 C<all> | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | Once the next signal is received that is I<greater> than C<irc_005>, | ||||||||||||||||||||||||||||
| 213 | it emits an C<irc_isupport> signal. | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =head1 OUTPUT EVENTS | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =head2 C<irc_isupport> | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | Emitted by: the first signal received after C<irc_005> | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | C<ARG0> will be the plugin object itself for ease of use. | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | This is emitted when the support report has finished. | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | Jeff C<japhy> Pinyan, F<japhy@perlmonk.org> | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | L<POE::Component::IRC|POE::Component::IRC> | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | L<POE::Component::IRC::Plugin|POE::Component::IRC::Plugin> | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =cut | ||||||||||||||||||||||||||||