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