home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
1.x
/
plum10b8.lzh
/
plum10b8
/
dailylog.plm
< prev
next >
Wrap
Text File
|
1997-06-25
|
4KB
|
129 lines
package dailylog;
$DAILYLOG = 'log%m%d';
$LOGHEADER = '%h:%m';
$_ = 'dailylog';
sub ss_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan);
if ($chan =~ /^[\#\&]/) {
$vchan = &'vchan($chan);
if (&'exist($'nameslist{$'userno[$serverno], $chan}, $nick, "\+$nick", "\@$nick")) {
&dailylog($'userno[$serverno], "<$vchan:$nick> $msg");
} else {
&dailylog($'userno[$serverno], "($vchan:$nick) $msg");
}
} else {
&dailylog($'userno[$serverno], "=$nick= $msg");
}
return ($prefix, $cmd, $chan, $msg);
}
sub ss_join {
local($serverno, $prefix, $cmd, $chan) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "+ $nick ($prefix) to $vchan");
return ($prefix, $cmd, $chan);
}
sub ss_part {
local($serverno, $prefix, $cmd, $chan) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "- $nick from $vchan");
return ($prefix, $cmd, $chan);
}
sub ss_kick {
local($serverno, $prefix, $cmd, $chan, $whom, $reason) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "- $whom by $nick from $vchan ($reason)");
return ($prefix, $cmd, $chan, $whom, $reason);
}
sub ss_invite {
local($serverno, $prefix, $cmd, $me, $chan) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "Invited by $nick: $vchan");
return ($prefix, $cmd, $me, $chan);
}
sub ss_mode {
local($serverno, $prefix, $cmd, $chan, @modes) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "Mode by $nick: $vchan " . join(' ', @modes));
return ($prefix, $cmd, $chan, @modes);
}
sub ss_nick {
local($serverno, $prefix, $cmd, $newnick) = @_;
local($nick, $user, $host) = &'prefix($prefix);
if ($nick eq $'nick[$serverno] || $newnick eq $'nick[$serverno]) {
&dailylog($'userno[$serverno], "My nick is changed ($nick -> $newnick)");
} else {
&dailylog($'userno[$serverno], "$nick -> $newnick");
}
return ($prefix, $cmd, $newnick);
}
sub ss_quit {
local($serverno, $prefix, $cmd, $msg) = @_;
local($nick, $user, $host) = &'prefix($prefix);
&dailylog($'userno[$serverno], "! $nick ($msg)");
return ($prefix, $cmd, $msg);
}
sub ss_topic {
local($serverno, $prefix, $cmd, $chan, $topic) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], "Topic of channel $vchan by $nick: $topic");
return ($prefix, $cmd, $chan, $topic);
}
sub sp_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($vchan) = &'vchan($chan);
&dailylog($'userno[$serverno], ">$vchan:$'nick[$serverno]< $msg");
return ($prefix, $cmd, $chan, $msg);
}
sub dailylog {
local($userno, $msg) = @_;
local($file, $header, $filemode, $tmp, @time);
$file = &'property($userno, 'dailylog');
$file = &'expand($file || $DAILYLOG);
@time = localtime(time);
$tmp = sprintf('%04d', $time[5] + 1900);
$file =~ s/\%y/$tmp/g;
$tmp = sprintf('%02d', $time[4] + 1);
$file =~ s/\%m/$tmp/g;
$tmp = sprintf('%02d', $time[3]);
$file =~ s/\%d/$tmp/g;
$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;
if (!-f $file && open(TMP, ">$file")) {
close(TMP);
$filemode = oct(&'property($userno, 'filemode') || 0);
chmod(($filemode || (umask ^ 0666)) | 0200, $file);
}
if (open(DAILYLOG, ">>$file")) {
select((select(DAILYLOG), $| = 1)[0]);
print DAILYLOG $header, ' ', $msg, "\n";
close(DAILYLOG);
}
}