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

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