File Coverage

blib/lib/POE/Component/Server/IRC/Plugin/OperServ.pm
Criterion Covered Total %
statement 40 53 75.4
branch 9 26 34.6
condition 2 3 66.6
subroutine 8 8 100.0
pod 1 5 20.0
total 60 95 63.1


line stmt bran cond sub pod time code
1             package POE::Component::Server::IRC::Plugin::OperServ;
2             our $AUTHORITY = 'cpan:BINGOS';
3             $POE::Component::Server::IRC::Plugin::OperServ::VERSION = '1.60'; # TRIAL
4 2     2   3963 use strict;
  2         7  
  2         76  
5 2     2   12 use warnings;
  2         5  
  2         101  
6 2     2   13 use POE::Component::Server::IRC::Plugin qw(:ALL);
  2         6  
  2         1713  
7              
8             sub new {
9 1     1 1 15 my ($package, %args) = @_;
10 1         12 return bless \%args, $package;
11             }
12              
13             sub PCSI_register {
14 1     1 0 125 my ($self, $ircd) = splice @_, 0, 2;
15              
16 1         9 $ircd->plugin_register($self, 'SERVER', qw(daemon_privmsg daemon_join));
17 1         73 $ircd->yield(
18             'add_spoofed_nick',
19             {
20             nick => 'OperServ',
21             umode => 'Doi',
22             ircname => 'The OperServ bot',
23             },
24             );
25 1         135 return 1;
26             }
27              
28             sub PCSI_unregister {
29 1     1 0 424 return 1;
30             }
31              
32             sub IRCD_daemon_privmsg {
33 2     2 0 96 my ($self, $ircd) = splice @_, 0, 2;
34 2         5 my $nick = (split /!/, ${ $_[0] })[0];
  2         10  
35              
36 2 50       13 return PCSI_EAT_NONE if !$ircd->state_user_is_operator($nick);
37 2         6 my $request = ${ $_[2] };
  2         5  
38              
39             SWITCH: {
40 2 100       5 if (my ($chan) = $request =~ /^clear\s+(#.+)\s*$/i) {
  2         15  
41 1 50       19 last SWITCH if !$ircd->state_chan_exists($chan);
42 1         8 $ircd->yield('daemon_cmd_sjoin', 'OperServ', $chan);
43 1         105 last SWITCH;
44             }
45 1 50       13 if (my ($chan) = $request =~ /^join\s+(#.+)\s*$/i) {
46 1 50       4 last SWITCH if !$ircd->state_chan_exists($chan);
47 1         6 $ircd->yield('daemon_cmd_join', 'OperServ', $chan);
48 1         96 last SWITCH;
49             }
50 0 0       0 if (my ($chan) = $request =~ /^part\s+(#.+)\s*$/i) {
51 0 0       0 last SWITCH unless $ircd->state_chan_exists($chan);
52 0         0 $ircd->yield('daemon_cmd_part', 'OperServ', $chan);
53 0         0 last SWITCH;
54             }
55 0 0       0 if (my ($chan, $mode) = $request =~ /^mode\s+(#.+)\s+(.+)\s*$/i) {
56 0 0       0 last SWITCH if !$ircd->state_chan_exists($chan);
57 0         0 $ircd->yield('daemon_cmd_mode', 'OperServ', $chan, $mode);
58 0         0 last SWITCH;
59             }
60 0 0       0 if (my ($chan, $target) = $request =~ /^op\s+(#.+)\s+(.+)\s*$/i) {
61 0 0       0 last SWITCH unless $ircd->state_chan_exists($chan);
62 0         0 $ircd->daemon_server_mode($chan, '+o', $target);
63             }
64             }
65              
66 2         7 return PCSI_EAT_NONE;
67             }
68              
69             sub IRCD_daemon_join {
70 5     5 0 253 my ($self, $ircd) = splice @_, 0, 2;
71 5         14 my $nick = (split /!/, ${ $_[0] })[0];
  5         25  
72 5 100 66     22 if (!$ircd->state_user_is_operator($nick) || $nick eq 'OperServ') {
73 3         10 return PCSI_EAT_NONE;
74             }
75 2         6 my $channel = ${ $_[1] };
  2         6  
76 2 50       12 return PCSI_EAT_NONE if $ircd->state_is_chan_op($nick, $channel);
77 0           $ircd->daemon_server_mode($channel, '+o', $nick);
78 0           return PCSI_EAT_NONE;
79             }
80              
81             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 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
108              
109             =head1 METHODS
110              
111             =head2 C
112              
113             Returns a plugin object suitable for feeding to
114             L's C
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
163              
164             =cut