home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
1.x
/
plum12.lzh
/
plum12
/
taillog.plm
< prev
next >
Wrap
Text File
|
1997-09-25
|
2KB
|
59 lines
package taillog;
$LOGHEADER = '%h:%m';
$TAILLOG = 50;
$_ = 'taillog';
sub client_open {
local($clientno) = @_;
foreach $log (&'array($taillog[$'userno[$clientno]])) {
&'c_print($clientno, '', 'NOTICE', $'nick[$clientno], $log);
}
}
sub sp_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($vchan) = &'vchan($chan);
&makelog($'userno[$serverno], ">$vchan:$'nick[$serverno]< $msg");
return ($prefix, $cmd, $chan, $msg);
}
sub ss_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($nick, $vchan);
$nick = &'prefix($prefix);
if ($chan =~ /^[\#\&]/) {
$vchan = &'vchan($chan);
if (&'exist($'nameslist{$'userno[$serverno], $chan}, $nick, "\+$nick", "\@$nick")) {
&makelog($'userno[$serverno], "<$vchan:$nick> $msg");
} else {
&makelog($'userno[$serverno], "($vchan:$nick) $msg");
}
} else {
&makelog($'userno[$serverno], "=$nick= $msg");
}
return ($prefix, $cmd, $chan, $msg);
}
sub makelog {
local($userno, $log) = @_;
local(@time, @log, $header, $line, $tmp);
@time = localtime(time);
$header = &'property($userno, 'logheader') || $LOGHEADER;
$tmp = sprintf('%02d', $time[2]);
$header =~ s/\%h/$tmp/g;
$tmp = sprintf('%02d', $time[1]);
$header =~ s/\%m/$tmp/g;
$tmp = sprintf('%02d', $time[0]);
$header =~ s/\%s/$tmp/g;
@log = &'array($taillog[$userno]);
push(@log, "$header $log");
$line = &'property($userno, 'taillog') || $TAILLOG;
while (scalar(@log) > $line) {
shift(@log);
}
$taillog[$userno] = &'list(@log);
}