Component/IRC/Plugin/NickServID.pm

filter: Statementstmt 30.5% 18 / 59 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 41.6% 5 / 12 Podpod 14.2% 1 / 7 totaltotal 24.7% 24 / 97 CC 9 SCAR 21.7
CC
9
Cov
24%
S_notice
20.0
new
12.0
S_433
12.0
CRAP 8.8
« Component/IRC/Plugin/FollowTail.pm ↑ Summary Component/IRC/Plugin/Connector.pm »
1 package POE::Component::IRC::Plugin::NickServID;
2 1 our $AUTHORITY = 'cpan:HINRIK';
3 1 $POE::Component::IRC::Plugin::NickServID::VERSION = '6.92';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use IRC::Utils qw( uc_irc parse_user );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use POE::Component::IRC::Plugin qw( :ALL );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 0 ▶ my ($package) = shift;
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
12 0 ▶ croak "$package requires an even number of arguments" if @_ & 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ & 1 0 0 0
13 0 my %self = @_;
14  
15 0 ▶ die "$package requires a Password" if !defined $self{Password};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self{"Password"} 0 0 0
16 0 return bless \%self, $package;
17 }
18  
19 sub PCI_register {
20 0 ▶ my ($self, $irc) = @_;
Subroutine PCI_register: not called CC=1 SCAR=6.9
Pod undocumented
21 0 $self->{nick} = $irc->{nick};
22 0 $self->{irc} = $irc;
23 0 $irc->plugin_register($self, 'SERVER', qw(isupport nick notice));
24 0 return 1;
25 }
26  
27 sub PCI_unregister {
28 0 ▶ return 1;
Subroutine PCI_unregister: not called CC=1 SCAR=6.9
Pod undocumented
29 }
30  
31 # we identify after S_isupport so that pocoirc has a chance to turn on
32 # CAPAB IDENTIFY-MSG (if the server supports it) before the AutoJoin
33 # plugin joins channels
34 sub S_isupport {
35 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_isupport: not called CC=1 SCAR=6.9
Pod undocumented
36 0 $irc->yield(nickserv => "IDENTIFY $self->{Password}");
37 0 return PCI_EAT_NONE;
38 }
39  
40 sub S_nick {
41 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_nick: not called CC=2 SCAR=17.9
Pod undocumented
42 0 my $mapping = $irc->isupport('CASEMAPPING');
43 0 my $new_nick = uc_irc( ${ $_[1] }, $mapping );
44  
45 0 ▶ if ( $new_nick eq uc_irc($self->{nick}, $mapping) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_nick eq uc_irc($self->{"nick"}, $mapping)) 0 0 0
46 0 $irc->yield(nickserv => "IDENTIFY $self->{Password}");
47 }
48 0 return PCI_EAT_NONE;
49 }
50  
51 sub S_notice {
52 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_notice: not called CC=4 SCAR=30.0
Pod undocumented
53 0 my $sender = parse_user(${ $_[0] });
54 0 my $recipient = parse_user(${ $_[1] }->[0]);
55 0 my $msg = ${ $_[2] };
56  
57 0 ▶ return PCI_EAT_NONE if $recipient ne $irc->nick_name();
Branch: 1 branch
BranchTrueFalseTotal
if $recipient ne $irc->nick_name 0 0 0
58 0 ▶ return PCI_EAT_NONE if $sender !~ /^nickserv$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $sender =~ /^nickserv$/i 0 0 0
59 0 ▶ return PCI_EAT_NONE if $msg !~ /now (?:identified|recognized)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg =~ /now (?:identified|recognized)/ 0 0 0
60 0 $irc->send_event_next('irc_identified');
61 0 return PCI_EAT_NONE;
62 }
63  
64 # ERR_NICKNAMEINUSE
65 sub S_433 {
66 0 ▶ my ($self, $irc) = splice @_, 0, 2;
Subroutine S_433: not called CC=3 SCAR=24.8
Pod undocumented
67 0 my $offending = ${ $_[2] }->[0];
68 0 my $reason = ${ $_[2] }->[1];
69  
70 0 ▶ if ($irc->nick_name() eq $offending && $reason eq "Nickname is registered to someone else") {
Branch: 1 branch
BranchTrueFalseTotal
if ($irc->nick_name eq $offending and $reason eq "Nickname is registered to someone else") 0 0 0
Condition0%0/3
$irc->nick_name eq $offending and $reason eq "Nickname is registered to someone else"
!ll&&!rl&&r
000
MC/DC0%0/2
$irc->nick_name eq $offending and $reason eq "Nickname is registered to someone else"
$irc->nick_name eq $offending $reason eq "Nickname is registered to someone else"
Truth table0%0/3
A and B
A= $irc->nick_name eq $offendingB= $reason eq "Nickname is registered to someone else"
ABresult
0X0
100
111
71 0 $irc->yield(nickserv => "IDENTIFY $self->{Password}");
72 }
73  
74 0 return PCI_EAT_NONE;
75 }
76 1 1;
77  
78 =encoding utf8
79  
80 =head1 NAME
81  
82 POE::Component::IRC::Plugin::NickServID - A PoCo-IRC plugin which identifies with NickServ when needed
83  
84 =head1 SYNOPSIS
85  
86 use POE::Component::IRC::Plugin::NickServID;
87  
88 $irc->plugin_add( 'NickServID', POE::Component::IRC::Plugin::NickServID->new(
89 Password => 'opensesame'
90 ));
91  
92 =head1 DESCRIPTION
93  
94 POE::Component::IRC::Plugin::NickServID is a L<POE::Component::IRC|POE::Component::IRC>
95 plugin. It identifies with NickServ on connect and when you change your nick,
96 if your nickname matches the supplied password.
97  
98 B<Note>: If you have a cloak and you don't want to be seen without it, make sure
99 you don't join channels until after you've identified yourself. If you use the
100 L<AutoJoin plugin|POE::Component::IRC::Plugin::AutoJoin>, it will be taken
101 care of for you.
102  
103 =head1 METHODS
104  
105 =head2 C<new>
106  
107 Arguments:
108  
109 'Password', the NickServ password.
110  
111 Returns a plugin object suitable for feeding to
112 L<POE::Component::IRC|POE::Component::IRC>'s plugin_add() method.
113  
114 =head1 OUTPUT EVENTS
115  
116 =head2 C<irc_identified>
117  
118 This event will be sent when you have identified with NickServ. No arguments
119 are passed with it.
120  
121 =head1 AUTHOR
122  
123 Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com
124  
125 =cut
« Component/IRC/Plugin/FollowTail.pm ↑ Summary Component/IRC/Plugin/Connector.pm »