Component/IRC/Plugin/NickServID.pm

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