home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_15_2.lzh
/
module
/
log
/
channel.plm
next >
Wrap
Text File
|
1997-11-23
|
10KB
|
326 lines
# <!-- -*- perl -*-
# $Id: channel.plm,v 2.2 1997/11/22 01:51:09 hasegawa Exp $
# copyright (c)1997 pupu_j <hasegawa@agusa.nuie.nagoya-u.ac.jp>
package log_channel;
$DIRECTORY = '.';
$HEADER = '%H:%M';
$MODE = umask() ^ 0666;
$SAVE = &'list('privmsg', 'join', 'part', 'kick' ,'invite', 'mode', 'nick', 'quit', 'topic');
$_ = 'log_channel';
sub ss_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($chan =~ /^[\#\&\+\-]/) {
$vchan = &'alias($chan);
if (&'exist($'nameslist{$'userno[$serverno], $chan}, $nick, "\+$nick", "\@$nick")) {
&writelog($'userno[$serverno], $chan, "<$vchan:$nick> $msg");
} else {
&writelog($'userno[$serverno], $chan, "($vchan:$nick) $msg");
}
} else {
&writelog($'userno[$serverno], '', "=$nick= $msg");
}
}
return ($prefix, $cmd, $chan, $msg);
}
sub ss_notice {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($chan =~ /^[\#\&\+\-]/) {
$vchan = &'alias($chan);
if (&'exist($'nameslist{$'userno[$serverno], $chan}, $nick, "\+$nick", "\@$nick")) {
&writelog($'userno[$serverno], $chan, "<$vchan:$nick> $msg");
} else {
&writelog($'userno[$serverno], $chan, "($vchan:$nick) $msg");
}
} else {
&writelog($'userno[$serverno], '', "=$nick= $msg");
}
}
return ($prefix, $cmd, $chan, $msg);
}
sub ss_join {
local($serverno, $prefix, $cmd, $chan) = @_;
local($nick, $name, $mode, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
($name, $mode) = (split(/\cG/, $chan), '');
$vchan = &'alias($name);
if (index($mode, 'o') != -1) {
&writelog($'userno[$serverno], $name, "+ \@$nick ($prefix) to $vchan");
} elsif (index($mode, 'v') != -1) {
&writelog($'userno[$serverno], $name, "+ +$nick ($prefix) to $vchan");
} else {
&writelog($'userno[$serverno], $name, "+ $nick ($prefix) to $vchan");
}
}
return ($prefix, $cmd, $chan);
0}
sub ss_part {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($chan);
$msg = '' unless $msg;
&writelog($'userno[$serverno], $chan, "- $nick from $vchan ($msg)");
}
return ($prefix, $cmd, $chan, $msg);
}
sub ss_kick {
local($serverno, $prefix, $cmd, $chan, $whom, $msg) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($chan);
&writelog($'userno[$serverno], $chan, "- $whom by $nick from $vchan ($msg)");
}
return ($prefix, $cmd, $chan, $whom, $msg);
}
sub ss_invite {
local($serverno, $prefix, $cmd, $me, $chan) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($chan);
&writelog($'userno[$serverno], $chan, "Invited by $nick: $vchan");
}
return ($prefix, $cmd, $me, $chan);
}
sub ss_mode {
local($serverno, $prefix, $cmd, $chan, @modes) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($chan);
&writelog($'userno[$serverno], $chan, "Mode by $nick: $vchan " . join(' ', @modes));
}
return ($prefix, $cmd, $chan, @modes);
}
sub ss_nick {
local($serverno, $prefix, $cmd, $newnick) = @_;
local($nick);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
if ($newnick eq $'nick[$serverno]) {
&writelog($'userno[$serverno], $newnick, "My nick is changed ($nick -> $newnick)");
} else {
&writelog($'userno[$serverno], $newnick, "$nick -> $newnick");
}
}
return ($prefix, $cmd, $newnick);
}
sub ss_quit {
local($serverno, $prefix, $cmd, $msg) = @_;
local($nick);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
&writelog($'userno[$serverno], $nick, "! $nick ($msg)");
}
return ($prefix, $cmd, $msg);
}
sub ss_topic {
local($serverno, $prefix, $cmd, $chan, $topic) = @_;
local($nick, $vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$nick = &'prefix($prefix);
$vchan = &'alias($chan);
&writelog($'userno[$serverno], $chan, "Topic of channel $vchan by $nick: $topic");
}
return ($prefix, $cmd, $chan, $topic);
}
sub sp_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($vchan);
if (&savecommand($'userno[$serverno], $cmd)) {
$vchan = &'alias($chan);
&writelog($'userno[$serverno], $chan, ">$vchan:$'nick[$serverno]< $msg");
}
return ($prefix, $cmd, $chan, $msg);
}
sub savecommand {
local($userno, $cmd) = @_;
local($save);
$save = &'property($userno, 'save');
if (defined($save)) {
$save = '';
foreach $mask (&'property($userno, 'save')) {
$save = &'add($save, split(/\,/, "\L$mask\U"));
}
} else {
$save = $SAVE;
}
return &'exist($save, "\L$cmd\E");
}
sub writelog {
local($userno, $chan, $msg) = @_;
local($chanlist, $rchan, $file);
if ($chan eq '') {
foreach $list (&'property($userno, 'file')) {
($file, $chans) = (split(/\s+/, $list), '');
if ($chans eq '') {
&channellog($userno, $file, $msg);
last;
}
}
} elsif ($chan =~ /^[\#\&\+\-]/) {
foreach $list (&'property($userno, 'file')) {
($file, $chans) = (split(/\s+/, $list), '');
$chanlist = '';
foreach $name (split(/\,/, $chans)) {
$chanlist = &'add($chanlist, &'real($name));
}
if (&'exist($chanlist, $chan) || $chanlist eq '') {
&channellog($userno, $file, $msg);
last;
}
}
} else {
foreach $list (&'property($userno, 'file')) {
($file, $chans) = (split(/\s+/, $list), '');
foreach $name (split(/\,/, $chans)) {
$rchan = &'real($name);
if (&'exist($'nameslist{$userno, $rchan}, $chan, "\+$chan", "\@$chan")) {
&channellog($userno, $file, $msg);
last;
}
}
}
}
}
sub channellog {
local($userno, $file, $msg) = @_;
local($directory, $name, $header, $mode, $kanji);
$file = &'expand($file);
if ($file =~ /^\//) {
$name = $file;
} else {
$directory = &'property($userno, 'directory');
$directory = $DIRECTORY unless defined($directory);
$directory = &'expand($directory);
$directory .= '/' unless $directory =~ /\/$/;
$name = $directory . $file;
}
$name = &'date($name);
$header = &'property($userno, 'header');
$header = $HEADER unless defined($header);
$header = &'date($header);
$kanji = &'property($userno, 'kanji') || '';
if ("\L$kanji\E" eq 'euc') {
$msg = &'jis_euc($msg);
} elsif ("\L$kanji\E" eq 'jis') {
$msg = &'jis_jis($msg);
} elsif ("\L$kanji\E" eq 'sjis') {
$msg = &'jis_sjis($msg);
}
if (!-w $name) {
if (!-f $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);
}
}
__END__
--><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><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$7$FJ]B8$9$k(B
<HR><H3> $B@bL@(B </H3>
$B%A%c%s%M%k$4$H$K%U%!%$%k$r;XDj$7$F%m%0$rJ]B8$7$^$9!#(B
<H3> $B%W%m%Q%F%#(B </H3>
<DL>
<DT> log.channel.directory $B%G%#%l%/%H%j(B
<DD> $B%m%0$r:n@.$9$k%G%#%l%/%H%j$r;XDj$7$^$9!#(B
$B%G%#%l%/%H%j$O(Bplum$B$r<B9T$7$?%G%#%l%/%H%j$+$i$NAjBP%Q%9$K$J$j$^$9!#(B
UNIX$B$J$i!V(B~/$B!W$d!V(B~user$B!W$H$$$&;XDj$b$G$-$^$9!#(B
<DT> log.channel.file* $B%U%!%$%kL>(B [($B%A%c%s%M%k(B)]
<DD> $B%m%0$N%U%!%$%kL>$HJ]B8$9$k%A%c%s%M%k$r;XDj$7$^$9!#(B
%$B$G$O$8$^$kJ8;z$,$"$k$HBP1~$9$kF|IU$KJQ49$5$l$^$9!#(B
$BF1$8%A%c%s%M%k$,J#?t$N%U%!%$%k$K;XDj$5$l$F$$$?$H$-$O!"(B
$B:G=i$K=q$$$?%U%!%$%k$K$@$1J]B8$7$^$9!#(B
$B$^$?!"%A%c%s%M%kL>$r>JN,$9$k$H!"(B
$B;D$j$N$9$Y$F$N%m%0$,$=$N%U%!%$%k$KJ]B8$5$l$^$9!#(B
<DT> log.channel.header $B$X%C%@(B
<DD> $B%m%0$K=PNO$9$k;~9o$N%U%)!<%^%C%H$r;XDj$7$^$9!#(B
%$B$G$O$8$^$kJ8;z$,$"$k$HBP1~$9$k;~4V$KJQ49$5$l$^$9!#(B
<DT> log.channel.mode $B%U%!%$%k%b!<%I(B
<DD> $B%m%0$N%U%!%$%k%b!<%I$r$3$3$G;XDj$7$?CM$K$7$^$9!#(B
<DT> log.channel.kanji {euc|jis|sjis}
<DD> $B=PNO$9$k%m%0$N4A;z%3!<%I$r;XDj$7$^$9!#(B
<DT> log.channel.save ({invite|join|kick|mode|nick|notice|part|privmsg|quit|topic})
<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
</DL>
<HR><H3> $B@_DjNc(B </H3>
<PRE>
+ log/channel.plm
log.channel.directory: log
log.channel.file: log%m%d #$B$^$I$+(B,#$B$^$I$+(B:*.jp
log.channel.kanji: sjis
</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.save: privmsg,notice,topic
</PRE>
$B!V(B#$B$^$I$+!W$N%m%0$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>