blib/lib/POE/Component/Server/IRC/Plugin/OperServ.pm

filter: Statementstmt 76.7% 43 / 56 Branchbran 34.6% 9 / 26 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 20.0% 1 / 5 totaltotal 64.0% 64 / 100 CC 15 SCAR 30.3
CC
15
Cov
64%
IRCD_daemon_privmsg
36.1
IRCD_daemon_join
4.2
BEGIN
1.0
CRAP 20.7
« blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm ↑ Summary blib/lib/POE/Component/Server/IRC/Backend.pm »
1 package POE::Component::Server::IRC::Plugin::OperServ;
2 2 our $AUTHORITY = 'cpan:BINGOS';
3 2 $POE::Component::Server::IRC::Plugin::OperServ::VERSION = '1.62';
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use POE::Component::Server::IRC::Plugin qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 1 ▶ my ($package, %args) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 1 return bless \%args, $package;
11 }
12  
13 sub PCSI_register {
14 1 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine PCSI_register: called CC=1 SCAR=0.0
Pod undocumented
15  
16 1 $ircd->plugin_register($self, 'SERVER', qw(daemon_privmsg daemon_join));
17 1 $ircd->yield(
18 'add_spoofed_nick',
19 {
20 nick => 'OperServ',
21 umode => 'Doi',
22 ircname => 'The OperServ bot',
23 },
24 );
25 1 return 1;
26 }
27  
28 sub PCSI_unregister {
29 1 ▶ return 1;
Subroutine PCSI_unregister: called CC=1 SCAR=0.0
Pod undocumented
30 }
31  
32 sub IRCD_daemon_privmsg {
33 2 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_daemon_privmsg: called CC=12 SCAR=35.9
Pod undocumented
34 2 my $nick = (split /!/, ${ $_[0] })[0];
35  
36 2 ▶ return PCSI_EAT_NONE if !$ircd->state_user_is_operator($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_user_is_operator($nick) 0 2 2
37 2 my $request = ${ $_[2] };
38  
39 SWITCH: {
40 2 ▶ if (my ($chan) = $request =~ /^clear\s+(#.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($chan) = $request =~ /^clear\s+(#.+)\s*$/i) 1 1 2
41 1 ▶ last SWITCH if !$ircd->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_chan_exists($chan) 0 1 1
42 1 $ircd->yield('daemon_cmd_sjoin', 'OperServ', $chan);
43 1 last SWITCH;
44 }
45 1 ▶ if (my ($chan) = $request =~ /^join\s+(#.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($chan) = $request =~ /^join\s+(#.+)\s*$/i) 1 0 1
46 1 ▶ last SWITCH if !$ircd->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_chan_exists($chan) 0 1 1
47 1 $ircd->yield('daemon_cmd_join', 'OperServ', $chan);
48 1 last SWITCH;
49 }
50 0 ▶ if (my ($chan) = $request =~ /^part\s+(#.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($chan) = $request =~ /^part\s+(#.+)\s*$/i) 0 0 0
51 0 ▶ last SWITCH unless $ircd->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_chan_exists($chan) 0 0 0
52 0 $ircd->yield('daemon_cmd_part', 'OperServ', $chan);
53 0 last SWITCH;
54 }
55 0 ▶ if (my ($chan, $mode) = $request =~ /^mode\s+(#.+)\s+(.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $request =~ /^mode\s+(#.+)\s+(.+)\s*$/i) 0 0 0
56 0 ▶ last SWITCH if !$ircd->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_chan_exists($chan) 0 0 0
57 0 $ircd->yield('daemon_cmd_mode', 'OperServ', $chan, $mode);
58 0 last SWITCH;
59 }
60 0 ▶ if (my ($chan, $target) = $request =~ /^op\s+(#.+)\s+(.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $request =~ /^op\s+(#.+)\s+(.+)\s*$/i) 0 0 0
61 0 ▶ last SWITCH unless $ircd->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $ircd->state_chan_exists($chan) 0 0 0
62 0 $ircd->daemon_server_mode($chan, '+o', $target);
63 }
64 }
65  
66 2 return PCSI_EAT_NONE;
67 }
68  
69 sub IRCD_daemon_join {
70 5 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_daemon_join: called CC=4 SCAR=14.4
Pod undocumented
71 5 my $nick = (split /!/, ${ $_[0] })[0];
72 5 ▶ if (!$ircd->state_user_is_operator($nick) || $nick eq 'OperServ') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ircd->state_user_is_operator($nick) or $nick eq "OperServ") 3 2 5
Condition66%2/3
not $ircd->state_user_is_operator($nick) or $nick eq "OperServ"
l!l&&r!l&&!r
032
MC/DC50%1/2
not $ircd->state_user_is_operator($nick) or $nick eq "OperServ"
not $ircd->state_user_is_operator($nick) $nick eq "OperServ"
Truth table66%2/3
not(A) or B
A= not $ircd->state_user_is_operator($nick)B= $nick eq "OperServ"
ABresult
1X1
011
000
73 3 return PCSI_EAT_NONE;
74 }
75 2 my $channel = ${ $_[1] };
76 2 ▶ return PCSI_EAT_NONE if $ircd->state_is_chan_op($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
if $ircd->state_is_chan_op($nick, $channel) 2 0 2
77 0 $ircd->daemon_server_mode($channel, '+o', $nick);
78 0 return PCSI_EAT_NONE;
79 }
80  
81 2 1;
82  
83 =encoding utf8
84  
85 =head1 NAME
86  
87 POE::Component::Server::IRC::Plugin::OperServ - An OperServ plugin for POE::Component::Server::IRC
88  
89 =head1 SYNOPSIS
90  
91 use POE::Component::Server::IRC::Plugin::OperServ;
92  
93 $ircd->plugin_add(
94 'OperServ',
95 POE::Component::Server::IRC::Plugin::OperServ->new(),
96 );
97  
98 =head1 DESCRIPTION
99  
100 POE::Component::Server::IRC::Plugin::OperServ is a
101 L<POE::Component::Server::IRC|POE::Component::Server::IRC> plugin which
102 provides simple operator services.
103  
104 This plugin provides a server user called OperServ. OperServ accepts
105 PRIVMSG commands from operators.
106  
107 /msg OperServ <command> <parameters>
108  
109 =head1 METHODS
110  
111 =head2 C<new>
112  
113 Returns a plugin object suitable for feeding to
114 L<POE::Component::Server::IRC|POE::Component::Server::IRC>'s C<plugin_add>
115 method.
116  
117 =head1 COMMANDS
118  
119 The following commands are accepted:
120  
121 =head2 clear CHANNEL
122  
123 The OperServ will remove all channel modes on the indicated channel,
124 including all users' +ov flags. The timestamp of the channel will be reset
125 and the OperServ will join that channel with +o.
126  
127 =head2 join CHANNEL
128  
129 The OperServ will simply join the channel you specify with +o.
130  
131 =head2 part CHANNEL
132  
133 The OperServ will part (leave) the channel specified.
134  
135 =head2 mode CHANNEL MODE
136  
137 The OperServ will set the channel mode you tell it to. You can also remove
138 the channel mode by prefixing the mode with a '-' (minus) sign.
139  
140 =head2 op CHANNEL USER
141  
142 The OperServ will give +o to any user on a channel you specify. OperServ
143 does not need to be in that channel (as this is mostly a server hack).
144  
145 Whenever the OperServ joins a channel (which you specify with the join
146 command) it will automatically gain +o.
147  
148 =head1 AUTHOR
149  
150 Chris 'BinGOs' Williams
151  
152 =head1 LICENSE
153  
154 Copyright C<(c)> Chris Williams
155  
156 This module may be used, modified, and distributed under the same terms as
157 Perl itself. Please see the license that came with your Perl distribution
158 for details.
159  
160 =head1 SEE ALSO
161  
162 L<POE::Component::Server::IRC|POE::Component::Server::IRC>
163  
164 =cut
« blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm ↑ Summary blib/lib/POE/Component/Server/IRC/Backend.pm »