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