Component/IRC/Plugin/Whois.pm

filter: Statementstmt 17.8% 23 / 129 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 6 / 20 Podpod 7.1% 1 / 14 totaltotal 17.5% 30 / 171 CC 5 SCAR 11.3
CC
5
Cov
17%
S_312
6.0
S_319
6.0
S_318
6.0
CRAP 3.1
« Component/IRC.pm ↑ Summary Filter/IRC.pm »
1 package POE::Component::IRC::Plugin::Whois;
2 79 our $AUTHORITY = 'cpan:HINRIK';
3 79 $POE::Component::IRC::Plugin::Whois::VERSION = '6.93';
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 79 ▶use POE::Component::IRC::Plugin qw( PCI_EAT_NONE );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 79 ▶use IRC::Utils qw(uc_irc);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 0 ▶ return bless { }, shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
12 }
13  
14 sub PCI_register {
15 0 ▶ my( $self, $irc ) = @_;
Subroutine PCI_register: not called CC=1 SCAR=6.9
Pod undocumented
16 0 $irc->plugin_register( $self, 'SERVER', qw(307 310 311 312 313 314 317 318 319 330 338 369) );
17 0 return 1;
18 }
19  
20 sub PCI_unregister {
21 0 ▶ return 1;
Subroutine PCI_unregister: not called CC=1 SCAR=6.9
Pod undocumented
22 }
23  
24 # RPL_WHOISUSER
25 sub S_311 {
26 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_311: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my $mapping = $irc->isupport('CASEMAPPING');
28 0 my @args = @{ ${ $_[2] } };
29 0 my $real = pop @args;
30 0 my ($rnick,$user,$host) = @args;
31 0 my $nick = uc_irc $rnick, $mapping;
32  
33 0 $self->{WHOIS}->{ $nick }->{nick} = $rnick;
34 0 $self->{WHOIS}->{ $nick }->{user} = $user;
35 0 $self->{WHOIS}->{ $nick }->{host} = $host;
36 0 $self->{WHOIS}->{ $nick }->{real} = $real;
37  
38 0 return PCI_EAT_NONE;
39 }
40  
41 # RPL_WHOISOPERATOR
42 sub S_313 {
43 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_313: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my $mapping = $irc->isupport('CASEMAPPING');
45 0 my $nick = uc_irc ${ $_[2] }->[0], $mapping;
46 0 my $oper = ${ $_[2] }->[1];
47  
48 0 $self->{WHOIS}->{ $nick }->{oper} = $oper;
49 0 return PCI_EAT_NONE;
50 }
51  
52 # RPL_WHOISSERVER
53 sub S_312 {
54 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_312: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my $mapping = $irc->isupport('CASEMAPPING');
56 0 my ($nick,$server) = @{ ${ $_[2] } };
57 0 $nick = uc_irc $nick, $mapping;
58  
59 # This can be returned in reply to either a WHOIS or a WHOWAS *sigh*
60 0 ▶ if ( defined $self->{WHOWAS}->{ $nick } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'WHOWAS'}{$nick}) { } 0 0 0
61 0 $self->{WHOWAS}->{ $nick }->{server} = $server;
62 }
63 else {
64 0 $self->{WHOIS}->{ $nick }->{server} = $server;
65 }
66  
67 0 return PCI_EAT_NONE;
68 }
69  
70 # RPL_WHOISIDLE
71 sub S_317 {
72 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_317: not called CC=1 SCAR=6.9
Pod undocumented
73 0 my $mapping = $irc->isupport('CASEMAPPING');
74 0 my ($nick,@args) = @{ ${ $_[2] } };
75 0 $nick = uc_irc $nick, $mapping;
76  
77 0 $self->{WHOIS}->{ $nick }->{idle} = $args[0];
78 0 $self->{WHOIS}->{ $nick }->{signon} = $args[1];
79  
80 0 return PCI_EAT_NONE;
81 }
82  
83 # RPL_WHOISCHANNELS
84 sub S_319 {
85 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_319: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my $mapping = $irc->isupport('CASEMAPPING');
87 0 my @args = @{ ${ $_[2] } };
88 0 my $nick = uc_irc shift ( @args ), $mapping;
89 0 my @chans = split / /, shift @args;
90  
91 0 ▶ if ( !defined $self->{WHOIS}->{ $nick }->{channels} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'WHOIS'}{$nick}{'channels'}) { } 0 0 0
92 0 $self->{WHOIS}->{ $nick }->{channels} = [ @chans ];
93 }
94 else {
95 0 push( @{ $self->{WHOIS}->{ $nick }->{channels} }, @chans );
96 }
97  
98 0 return PCI_EAT_NONE;
99 }
100  
101 # RPL_WHOISACCOUNT
102 sub S_330 {
103 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_330: not called CC=1 SCAR=6.9
Pod undocumented
104 0 my $mapping = $irc->isupport('CASEMAPPING');
105 0 my ($nick, $ident) = @{ ${ $_[2] } };
106  
107 0 $self->{WHOIS}->{ uc_irc ( $nick, $mapping ) }->{identified} = $ident;
108  
109 0 return PCI_EAT_NONE;
110 }
111  
112 {
113 79 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
114 79 *S_307 = \&S_330; # RPL_WHOISREGNICK
115 }
116  
117 # RPL_WHOISMODES
118 sub S_310 {
119 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_310: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my $mapping = $irc->isupport('CASEMAPPING');
121 0 my ($nick, $modes) = @{ ${ $_[2] } };
122  
123 0 $self->{WHOIS}->{ uc_irc ( $nick, $mapping ) }->{modes} = $modes;
124  
125 0 return PCI_EAT_NONE;
126 }
127  
128 # RPL_WHOISACTUALLY (Hybrid/Ratbox/others)
129 sub S_338 {
130 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_338: not called CC=1 SCAR=6.9
Pod undocumented
131 0 my $mapping = $irc->isupport('CASEMAPPING');
132 0 my $nick = uc_irc ${ $_[2] }->[0], $mapping;
133 0 my $ip = ${ $_[2] }->[1];
134  
135 0 $self->{WHOIS}->{ $nick }->{actually} = $ip;
136  
137 0 return PCI_EAT_NONE;
138 }
139  
140 # RPL_ENDOFWHOIS
141 sub S_318 {
142 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_318: not called CC=2 SCAR=17.9
Pod undocumented
143 0 my $mapping = $irc->isupport('CASEMAPPING');
144 0 my $nick = uc_irc ${ $_[2] }->[0], $mapping;
145 0 my $whois = delete $self->{WHOIS}->{ $nick };
146  
147 0 ▶ $irc->send_event_next( 'irc_whois', $whois ) if defined $whois;
Branch: 1 branch
BranchTrueFalseTotal
if defined $whois 0 0 0
148 0 return PCI_EAT_NONE;
149 }
150  
151 # RPL_WHOWASUSER
152 sub S_314 {
153 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_314: not called CC=1 SCAR=6.9
Pod undocumented
154 0 my $mapping = $irc->isupport('CASEMAPPING');
155 0 my @args = @{ ${ $_[2] } };
156 0 my $real = pop @args;
157 0 my ($rnick,$user,$host) = @args;
158 0 my $nick = uc_irc $rnick, $mapping;
159  
160 0 $self->{WHOWAS}->{ $nick }->{nick} = $rnick;
161 0 $self->{WHOWAS}->{ $nick }->{user} = $user;
162 0 $self->{WHOWAS}->{ $nick }->{host} = $host;
163 0 $self->{WHOWAS}->{ $nick }->{real} = $real;
164  
165 0 return PCI_EAT_NONE;
166 }
167  
168 # RPL_ENDOFWHOWAS
169 sub S_369 {
170 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_369: not called CC=2 SCAR=17.9
Pod undocumented
171 0 my $mapping = $irc->isupport('CASEMAPPING');
172 0 my $nick = uc_irc ${ $_[2] }->[0], $mapping;
173  
174 0 my $whowas = delete $self->{WHOWAS}->{ $nick };
175 0 ▶ $irc->send_event_next( 'irc_whowas', $whowas ) if defined $whowas;
Branch: 1 branch
BranchTrueFalseTotal
if defined $whowas 0 0 0
176 0 return PCI_EAT_NONE;
177 }
178  
179 79 1;
180  
181 =encoding utf8
182  
183 =head1 NAME
184  
185 POE::Component::IRC::Plugin::Whois - A PoCo-IRC plugin that generates events
186 for WHOIS and WHOWAS replies
187  
188 =head1 DESCRIPTION
189  
190 POE::Component::IRC::Plugin::Whois is the reimplementation of the C<irc_whois>
191 and C<irc_whowas> code from L<POE::Component::IRC|POE::Component::IRC> as a
192 plugin. It is used internally by L<POE::Component::IRC|POE::Component::IRC>
193 so there is no need to use this plugin yourself.
194  
195 =head1 METHODS
196  
197 =head2 C<new>
198  
199 No arguments required. Returns a plugin object suitable for feeding to
200 L<POE::Component::IRC|POE::Component::IRC>'s C<plugin_add> method.
201  
202  
203 =head1 AUTHOR
204  
205 Chris "BinGOs" Williams
206  
207 =head1 SEE ALSO
208  
209 L<POE::Component::IRC|POE::Component::IRC>
210  
211 L<POE::Component::IRC::Plugin|POE::Component::IRC::Plugin>
212  
213 =cut
« Component/IRC.pm ↑ Summary Filter/IRC.pm »