home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_28_2.lzh
/
module
/
log
/
channel.plm
next >
Wrap
Text File
|
1998-10-15
|
13KB
|
424 lines
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- $_ if 0; # -*- perl -*-
# $Id: channel.plm,v 2.23 1998/07/31 10:26:25 hasegawa Exp $
# copyright (c)1997-1998 pupu_j <hasegawa@agusa.nuie.nagoya-u.ac.jp>
package log_channel;
$DIRECTORY = '.';
$HEADER = '%H:%M';
$MODE = umask() ^ 0666;
$COMMAND = &'list('privmsg', 'join', 'part', 'kick' ,'invite', 'mode', 'nick', 'quit', 'topic');
$_ = 'log_channel';
sub ss_privmsg {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
if ($params[1] && &savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($params[0] =~ /^[\#\&\+]/) {
$vchan = &'alias($params[0]);
if (&'exist($nameslist{$serverno, $params[0]}, $nick)) {
&writelog($serverno, $params[0], "<$vchan:$nick> $params[1]");
} else {
&writelog($serverno, $params[0], "($vchan:$nick) $params[1]");
}
} else {
&writelog($serverno, '', "=$nick= $params[1]");
}
}
return ($prefix, $cmd, @params);
}
sub ss_notice {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
if ($params[1] && &savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($params[0] =~ /^[\#\&\+]/) {
$vchan = &'alias($params[0]);
if (&'exist($nameslist{$serverno, $params[0]}, $nick)) {
&writelog($serverno, $params[0], "<$vchan:$nick> $params[1]");
} else {
&writelog($serverno, $params[0], "($vchan:$nick) $params[1]");
}
} else {
&writelog($serverno, '', "=$nick= $params[1]");
}
}
return ($prefix, $cmd, @params);
}
sub ss_join {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $name, $mode, $vchan);
$nick = &'prefix($prefix);
($name, $mode) = (split(/\cG/, $params[0]), '');
if ($nick eq $'nick[$serverno]) {
$nameslist{$serverno, $name} = '';
} else {
$nameslist{$serverno, $name} = &'add($nameslist{$serverno, $name}, $nick);
}
if (&savecommand($'userno[$serverno], $cmd)) {
$vchan = &'alias($name);
if (index($mode, 'o') != -1) {
&writelog($serverno, $name, "+ \@$nick ($prefix) to $vchan");
} elsif (index($mode, 'v') != -1) {
&writelog($serverno, $name, "+ +$nick ($prefix) to $vchan");
} else {
&writelog($serverno, $name, "+ $nick ($prefix) to $vchan");
}
}
return ($prefix, $cmd, @params);
}
sub ss_part {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
$nick = &'prefix($prefix);
if (&savecommand($'userno[$serverno], $cmd)) {
$vchan = &'alias($params[0]);
&writelog($serverno, $params[0], "- $nick from $vchan ($params[1])");
}
if ($nick eq $'nick[$serverno]) {
delete $nameslist{$serverno, $params[0]};
} else {
$nameslist{$serverno, $params[0]} = &'remove($nameslist{$serverno, $params[0]}, $nick);
}
return ($prefix, $cmd, @params);
}
sub ss_kick {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
$nick = &'prefix($prefix);
if (&savecommand($'userno[$serverno], $cmd)) {
$vchan = &'alias($params[0]);
&writelog($serverno, $params[0], "- $params[1] by $nick from $vchan ($params[2])");
}
if ($nick eq $'nick[$serverno]) {
delete $nameslist{$serverno, $params[0]};
} else {
$nameslist{$serverno, $params[0]} = &'remove($nameslist{$serverno, $params[0]}, $params[1]);
}
return ($prefix, $cmd, @params);
}
sub ss_invite {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($params[1]);
&writelog($serverno, $params[1], "Invited by $nick: $vchan");
}
return ($prefix, $cmd, @params);
}
sub ss_mode {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan, @mode);
@mode = @params;
shift(@mode);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($params[0] =~ /^[\#\&\+]/) {
$vchan = &'alias($params[0]);
&writelog($serverno, $params[0], "Mode by $nick: $vchan " . join(' ', @mode));
} else {
&writelog($serverno, '', "Mode by $nick: $params[0] " . join(' ', @mode));
}
}
return ($prefix, $cmd, @params);
}
sub ss_nick {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick);
$nick = &'prefix($prefix);
if (&savecommand($'userno[$serverno], $cmd)) {
if ($params[0] eq $'nick[$serverno]) {
&writelog($serverno, $nick, "My nick is changed ($nick -\> $params[0])");
} else {
&writelog($serverno, $nick, "$nick -\> $params[0]");
}
}
foreach $chan (&'array($'channellist[$serverno])) {
$nameslist{$serverno, $chan} = &'change($nameslist{$serverno, $chan}, $nick, $params[0]);
}
return ($prefix, $cmd, @params);
}
sub ss_quit {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick);
$nick = &'prefix($prefix);
if (&savecommand($'userno[$serverno], $cmd)) {
&writelog($serverno, $nick, "! $nick ($params[0])");
}
foreach $chan (&'array($'channellist[$serverno])) {
$nameslist{$serverno, $chan} = &'remove($nameslist{$serverno, $chan}, $nick);
}
return ($prefix, $cmd, @params);
}
sub ss_topic {
local($serverno, $prefix, $cmd, @params) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($params[0]);
&writelog($serverno, $params[0], "Topic of channel $vchan by $nick: $params[1]");
}
return ($prefix, $cmd, @params);
}
sub ss_353 {
local($serverno, $prefix, $cmd, @params) = @_;
if (&'exist($'channellist[$serverno], $params[2])) {
foreach $name (split(/\s+/, $params[3])) {
$name =~ tr/\+\@//d;
$nameslist{$serverno, $params[2]} = &'add($nameslist{$serverno, $params[2]}, $name);
}
}
return ($prefix, $cmd, @params);
}
sub sp_privmsg {
local($serverno, $prefix, $cmd, @params) = @_;
local($chan, $vchan);
if ($params[1] && &savecommand($'userno[$serverno], $cmd)) {
foreach $chan (split(/\,/, $params[0])) {
if ($chan =~ /^[\#\&\+]/) {
$vchan = &'alias($chan);
&writelog($serverno, $chan, ">$vchan:$'nick[$serverno]< $params[1]");
} else {
&writelog($serverno, '', ">$chan< $params[1]");
}
}
}
return ($prefix, $cmd, @params);
}
sub sp_notice {
local($serverno, $prefix, $cmd, @params) = @_;
local($chan, $vchan);
if ($params[1] && &savecommand($'userno[$serverno], $cmd)) {
foreach $chan (split(/\,/, $params[0])) {
if ($chan =~ /^[\#\&\+]/) {
$vchan = &'alias($chan);
&writelog($serverno, $chan, ">$vchan:$'nick[$serverno]< $params[1]");
} else {
&writelog($serverno, '', ">$chan< $params[1]");
}
}
}
return ($prefix, $cmd, @params);
}
sub savecommand {
local($userno, $cmd) = @_;
local($save);
$save = &'property($userno, 'command');
if (defined($save)) {
$save = '';
foreach $mask (&'property($userno, 'command')) {
$save = &'add($save, split(/\,/, $mask));
}
} else {
$save = $COMMAND;
}
return &'exist($save, $cmd);
}
sub writelog {
local($serverno, $chan, $msg) = @_;
local($userno, $chanlist, $rchan, $file, $name, $list);
$userno = $'userno[$serverno];
if ($chan eq '') {
foreach $file (&'property($userno, 'file')) {
($name, $list) = split(/\s+/, $file);
if (!$list || &'exist(&'list(split(/\,/, $list)), '*')) {
&channellog($serverno, $name, $msg);
last;
}
}
} elsif ($chan =~ /^[\#\&\+]/) {
foreach $file (&'property($userno, 'file')) {
($name, $list) = split(/\s+/, $file);
$chanlist = '';
foreach $item (split(/\,/, $list || '')) {
$chanlist = &'add($chanlist, &'real($item));
}
if (&'exist($chanlist, $chan) || $chanlist eq '') {
&channellog($serverno, $name, $msg);
last;
}
}
} else {
foreach $file (&'property($userno, 'file')) {
($name, $list) = split(/\s+/, $file);
foreach $item (split(/\,/, $list || '')) {
$rchan = &'real($item);
if (&'exist($nameslist{$serverno, $rchan}, $chan)) {
&channellog($serverno, $name, $msg);
last;
}
}
}
}
}
sub channellog {
local($fileno, $file, $msg) = @_;
local($userno, $dir, $idx, $name, $code, $header, $mode);
$userno = $'userno[$fileno];
if (($idx = rindex($file, ';')) != -1) {
$name = substr($file, 0, $idx);
$code = substr($file, $idx + 1);
} else {
$name = $file;
$code = '';
}
$name = &'expand($name);
if ($name !~ /^[\\\/]/) {
$dir = &'expand(&'property($userno, 'directory') || $DIRECTORY);
$name = "$dir/$name";
}
$name = &'date($name);
$header = &'property($userno, 'header');
$header = $HEADER unless defined($header);
$header = &'date($header);
$msg = &jis_code($msg, $code) if $code;
$msg = &write_line($userno, $msg);
if (!-w $name) {
if (!-e $name && open(FILE, ">$name")) {
close(FILE);
}
$mode = &'property($userno, 'mode');
if (defined($mode)) {
$mode = oct($mode) | 0200;
} else {
$mode = $MODE | 0200;
}
chmod($mode, $name) if -f $name;
}
if (open(FILE, ">>$name")) {
select((select(FILE), $| = 1)[0]);
print FILE $header, ' ', $msg, "\n";
close(FILE);
}
}
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;
}
sub write_line {
local($userno, $line) = @_;
local($kanji, $code);
$kanji = &'property($userno, 'kanji');
if ($kanji) {
$code = (split(/\,/, "\L$kanji\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="mailto:hasegawa@agusa.nuie.nagoya-u.ac.jp">
<TITLE>log/channel.plm</TITLE></HEAD><BODY>
$B%*%s%i%$%s%I%-%e%a%s%H(B
<HR><H3>$BL>A0(B</H3>
log/channel.plm - $B%a%C%;!<%8$r%A%c%s%M%k$4$H$N%m%0$H$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3$G;XDj$7$?CM$K$7$^$9!#(B
</DD>
<DT> log.channel.command ({invite|join|kick|mode|nick|notice|part|privmsg|quit|topic})
</DT>
<DD> $BJ]B8$9$k%a%C%;!<%8$N<oN`$r;XDj$7$^$9!#(B
$B%G%U%)%k%H$G$O!V(Bnotice$B!W0J30$N$9$Y$F$G$9!#(B
</DD>
</DL>
<HR><H3>$B@_DjNc(B</H3>
<PRE>
+ log/channel.plm
log.channel.directory: log
log.channel.file: log%m%d;sjis #$B$^$I$+(B,#$B$^$I$+(B:*.jp
</PRE>
$B!V(B#$B$^$I$+!W$H!V(B#$B$^$I$+(B:*.jp$B!W$N%m%0$r!V(Blog/log%m%d$B!W$KJ]B8$7$^$9!#(B
$B$=$l0J30$N%A%c%s%M%k$N%m%0$OJ]B8$7$^$;$s!#(B
$B$^$?!"%m%0$N4A;z%3!<%I$r(Bsjis$B$K$7$^$9!#(B
<PRE>
+ log/channel.plm
log.channel.file: madoka/%m%d #$B$^$I$+(B,*
log.channel.file: log%m%d
log.channel.command: privmsg,notice,topic
</PRE>
$B!V(B#$B$^$I$+!W$N%m%0$H<+J,08$N%a%C%;!<%8$r!V(Bmadoka/log%m%d$B!W$KJ]B8$7!"(B
$B$=$l0J30$N%m%0$r!V(Blog%m%d$B!W$KJ]B8$7$^$9!#(B
$B!V(B%m$B!W$H!V(B%d$B!W$O$=$l$>$l8=:_$N7n$HF|$KJQ49$5$l$^$9!#(B
$B$^$?!"!V(Bprivmsg$B!W!"!V(Bnotice$B!W!"!V(Btopic$B!W0J30$N%m%0$OJ]B8$7$^$;$s!#(B
</BODY></HTML>