File: ServerOper.pm

package info (click to toggle)
tiarra 20100212-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,732 kB
  • ctags: 1,712
  • sloc: perl: 32,032; lisp: 193; sh: 109; makefile: 10
file content (45 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -----------------------------------------------------------------------------
# $Id: ServerOper.pm 11365 2008-05-10 14:58:28Z topia $
# -----------------------------------------------------------------------------
package User::ServerOper;
use strict;
use warnings;
use base qw(Module);

sub new {
    my $class = shift;
    my $this = $class->SUPER::new(@_);
    $this->{table} = do {
	# ネットワーク名 => [オペレータ名,オペレータパスワード]
	my %hash = map {
	    my ($network,$id,$pass) = m/^(.+?)\s+(.+?)\s+(.+)$/;
	    $network => [$id,$pass];
	} $this->config->oper('all');
	\%hash;
    };
    $this;
}

sub connected_to_server {
    my ($this,$server,$new_connection) = @_;
    my $oper = $this->{table}->{$server->network_name};
    if (defined $oper) {
	$server->send_message(
	    $this->construct_irc_message(
		Command => 'OPER',
		Params => [$oper->[0],$oper->[1]]));
    }
}

1;

=pod
info: 特定のネットワークに接続した時、OPERコマンドを発行します。
default: off

# 書式: <ネットワーク名> <オペレータ名> <オペレータパスワード>
#
# ネットワーク"local"に接続した時、オペレータ名oper、
# オペレータパスワードoper-passでOPERコマンドを発行する例。
-oper: local oper oper-pass
=cut