home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_32_1.lzh
/
module
/
auto
/
oper.plm
< prev
next >
Wrap
Text File
|
1999-02-20
|
11KB
|
368 lines
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- $_ if 0; # -*- perl -*-
# $Id: oper.plm,v 2.36 1999/01/28 14:55:19 hasegawa Exp $
# copyright (c)1997-1999 Yoshinori Hasegawa <hasegawa@madoka.org>
package auto_oper;
$_ = 'auto_oper';
sub ss_privmsg {
local($serverno, $prefix, $cmd, @params) = @_;
local($userno, $nick, %alias, $regex);
$userno = $'userno[$serverno];
$nick = &'prefix($prefix);
%alias = &get_alias_user($userno, $prefix);
$alias{'nick.now'} = $nick;
if (&'channel($params[0])) {
$alias{'channel'} = $params[0];
}
foreach $req (&'property($userno, 'request')) {
$regex = &'regex(&'jis_euc($req));
next unless &'jis_euc($params[1]) =~ /$regex/;
if (!&'channel($params[0])) {
foreach $reply (&'property($userno, 'private')) {
&privmsg($serverno, $nick, &'format($reply, %alias));
}
} elsif (!&'exist($'nameslist{$serverno, $params[0]}, $nick, "\+$nick", "\@$nick")) {
foreach $reply (&'property($userno, 'out')) {
&privmsg($serverno, $nick, &'format($reply, %alias));
}
} elsif (!&'exist($'nameslist{$serverno, $params[0]}, "\@$'nick[$serverno]")) {
foreach $reply (&'property($userno, 'notoper')) {
&privmsg($serverno, $params[0], &'format($reply, %alias));
}
} elsif (&'exist($'nameslist{$serverno, $params[0]}, "\@$nick")) {
foreach $reply (&'property($userno, 'oper')) {
&privmsg($serverno, $params[0], &'format($reply, %alias));
}
} elsif (!&check_mask($userno, $prefix, $params[0])) {
foreach $reply (&'property($userno, 'deny')) {
&privmsg($serverno, $params[0], &'format($reply, %alias));
}
} else {
foreach $reply (&'property($userno, 'message')) {
&privmsg($serverno, $params[0], &'format($reply, %alias));
}
&'s_print($serverno, '', 'MODE', $params[0], '+o', $nick);
}
last;
}
return ($prefix, $cmd, @params);
}
sub privmsg {
local($serverno, $to, $msg) = @_;
if ($msg) {
&'s_print($serverno, '', 'PRIVMSG', $to, $msg);
foreach $cno (&'array($'clientlist)) {
next unless $'avail[$cno];
next unless $'server[$cno] == $serverno;
&'c_print($cno, &'user($cno), 'PRIVMSG', $to, $msg);
}
}
}
sub check_mask {
local($userno, $prefix, $chan) = @_;
local($user, $chlist, $list);
foreach $mask (&'property($userno, 'mask')) {
($user, $chlist) = split(/\s+/, $mask);
$list = '';
foreach $vchan (split(/\,/, $chlist || '')) {
$list = &'add($list, &'real($vchan));
}
if (&'channel($chan)) {
next unless (!$list || &'exist($list, $chan));
} else {
next unless (!$list || &'exist($list, '*'));
}
if ($user =~ /^\-/) {
$regex = &'regex(substr($user, 1));
return 0 if $prefix =~ /$regex/i;
}
if ($user =~ /^\+/) {
$regex = &'regex(substr($user, 1));
} else {
$regex = &'regex($user);
}
return 1 if $prefix =~ /$regex/i;
}
return 0;
}
sub get_alias_user {
local($userno, $from, $prefix) = @_;
local($file, @list);
$file = &'property($userno, 'alias');
foreach $list (&split_list('nick', &read_file($file))) {
@list = &'array($list);
if (&match_alias_user($from, @list)) {
return &parse_alias($prefix, @list);
}
}
return ();
}
sub match_alias_user {
local($from, @list) = @_;
local($var, $arg, $regex);
foreach $line (@list) {
($var, $arg) = split(/\s+/, $line, 2);
next unless "\L$var\E" eq 'user';
$regex = &'regex($arg);
next unless $from =~ /$regex/i;
return 1;
}
return 0;
}
sub parse_alias {
local($prefix, @list) = @_;
local(%alias, $var, $arg, $key);
%alias = ();
foreach $line (@list) {
($var, $arg) = split(/\s+/, $line, 2);
$var = "\L$var\E";
if ($prefix) {
$key = $prefix . '.' . $var;
} else {
$key = $var;
}
next if defined($alias{$key});
if ($var eq 'nick') {
$alias{$key} = (split(/\,/, $arg))[0];
} elsif ($var eq 'name') {
$alias{$key} = (split(/\s+/, $arg))[0];
} else {
$alias{$key} = $arg;
}
}
return %alias;
}
sub split_list {
local($field, @list) = @_;
local($var, $arg, @array, @entry);
$field = "\L$field\E";
@array = ();
@entry = ();
foreach $line (@list) {
($var, $arg) = split(/\s*\:\s*/, $line, 2);
if ($field eq "\L$var\E") {
push(@array, &'list(@entry)) if @entry;
@entry = ();
}
push(@entry, $var . ' ' . $arg);
}
push(@array, &'list(@entry)) if @entry;
return @array;
}
sub read_file {
local($file) = @_;
local($name, $code, $mtime, @data, $line);
($name, $code) = &filename($file);
$mtime = (stat($name))[9];
if (defined($mtime)) {
$modify{$name} = -1 unless defined($modify{$name});
if ($modify{$name} != $mtime) {
if (open(TMP, $name)) {
@data = ();
while (defined($line = <TMP>)) {
$line =~ s/^\s+//;
next if $line =~ /^[\#\;]/;
$line =~ tr/\r\n//d;
next unless $line;
$line =~ s/\s+$//;
$line = &code_jis($line, $code) if $code;
push(@data, $line);
}
close(TMP);
$modify{$name} = $mtime;
$cache{$name} = &'list(@data);
return @data;
}
} else {
return &'array($cache{$name});
}
}
return ();
}
sub filename {
local($file) = @_;
local($idx, $name, $code);
return ('', '') unless $file;
if (($idx = rindex($file, ';')) != -1) {
$name = substr($file, 0, $idx);
$code = substr($file, $idx + 1);
} else {
$name = $file;
$code = '';
}
return (&'expand($name), $code);
}
sub code_jis {
local($line, $list) = @_;
foreach $code (split(/\,/, "\L$list\E")) {
if ($code eq 'euc') {
$line = &'euc_jis($line);
} elsif ($code eq 'jis') {
$line = &'jis_jis($line);
} elsif ($code eq 'sjis') {
$line = &'sjis_jis($line);
}
}
return $line;
}
sub jis_code {
local($line, $list) = @_;
local($code);
$code = (split(/\,/, "\L$list\E"))[0];
if ($code eq 'euc') {
$line = &'jis_euc($line);
} elsif ($code eq 'jis') {
$line = &'jis_jis($line);
} elsif ($code eq 'sjis') {
$line = &'jis_sjis($line);
}
return $line;
}
__END__
--><HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-2022-JP">
<LINK REV="made" HREF="mail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T>
<DD> $B%A%c%s%M%k%*%Z%l!<%?$rMW5a$5$l$?$H$-$K!"(B
$B<+J,$,%A%c%s%M%k%*%Z%l!<%?$G$J$$$?$a$K$=$N?M$r%A%c%s%M%k%*%Z%l!<%?$K(B
$B$G$-$J$$>l9g!"$3$3$G;XDj$7$?$b$N$rH/8@$7$^$9!#(B
#(nick)$B$N$h$&$K=q$/$3$H$G!"%(%$%j%"%9Cf$NBP1~$9$kCM$G(B
$BCV$-49$($^$9!#(B
</DD>
<DT> auto.oper.private* $B%U%)!<%^%C%H(B
</DT>
<DD> $B%A%c%s%M%k%*%Z%l!<%?$NMW5a$,%A%c%s%M%k$KBP$7$F$G$O$J$/!"(B
$B<+J,$KBP$7$F$5$l$?>l9g!"$3$3$G;XDj$7$?$b$N$rH/8@$7$^$9!#(B
#(nick)$B$N$h$&$K=q$/$3$H$G!"%(%$%j%"%9Cf$NBP1~$9$kCM$G(B
$BCV$-49$($^$9!#(B
</DD>
<DT> auto.oper.out* $B%U%)!<%^%C%H(B
</DT>
<DD> $B%A%c%s%M%k%*%Z%l!<%?$NMW5a$,%A%c%s%M%k$N30$+$iH/8@$5$l$?>l9g!"(B
$B$3$3$G;XDj$7$?$b$N$rH/8@$7$^$9!#(B
#(nick)$B$N$h$&$K=q$/$3$H$G!"%(%$%j%"%9Cf$NBP1~$9$kCM$G(B
$BCV$-49$($^$9!#(B
</DD>
</DL>
<HR><H3>$B@_DjNc(B</H3>
<PRE>
+ auto/oper.plm
auto.oper.alias: alias.txt;euc
auto.oper.request: $B$W$i$`$J$k$H(B
auto.oper.mask: +*!*@*
auto.oper.message: $B$O!A$$!y(B
auto.oper.deny: $B$J$k$H$O$"$2$i$l$^$;$s$o!#(B
auto.oper.oper: #(name|nick.now)$B$5$s$O$b$&$J$k$H;}$C$F$^$9$h!#(B
auto.oper.notoper: $B$4$a$s$J$5$$!#$J$k$H;}$C$F$J$$$s$G$9!#(B
auto.oper.private: $B$J$k$H$,$[$7$$%A%c%s%M%k$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