IRC/Plugin/OperServ.pm

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