# Modified by Tim Riker <Tim@Rikers.org>
# to work with infobot logs
-# then modified again for blootbot
+# then modified again for infobot
# Usage: irclog2html <date> < logfile
<a href="mailto:jdub\@NOSPAMaphid.net">Jeff Waugh</a> - find it at
<a href="http://freshmeat.net/appindex/2000/03/28/954251322.html">freshmeat.net</a>!
Modified by <a href="http://www.Rikers.org">Tim Riker</a> to work with
-<a href="http://blootbot.sourceforge.net/">blootbot</a> logs, split per channel, etc.
+<a href="http://infobot.sourceforge.net/">infobot</a> logs, split per channel, etc.
</body></html>
};
return $return;
foreach $filename (@files) {
chomp $filename;
if (!open(OUTPUT, ">>$filename")) {
- die "Cannot open $filename for writing!\n\n";
+ print "Cannot open $filename for writing!\n\n";
+ return;
}
print OUTPUT footer();
close OUTPUT;
mkdir($channel,oct('755')) if ($channel && ! -d $channel);
if (!open(OUTPUT, ">>$filename")) {
- die "Cannot open $filename for writing!\n\n";
+ #print "Cannot open $filename for writing!\n\n";
+ return;
}
# Begin output #
print OUTPUT header($channel, $date) if -z $filename;
}
sub output_timeservermsg {
- my ($date, $time, $line) = @_;
+ my ($date, $time, $channel, $line) = @_;
my $lineout = '';
if ($STYLE =~ /table/) {
$lineout .= "$time " if $time;
$lineout .= "$line<br>\n";
}
- output_line($date, $time,'',$lineout);
+ output_line($date, $time, $channel, $lineout);
}
sub html_rgb
chomp $line;
if (!$line eq "") {
-
-
# parse out the time
if ($line =~ s/^([0-9:\.]*) (.*)$/$2/) {
$time = $1;
} else {
- $time = "";
+ $time = '';
}
+ $channel = '';
# Replace ampersands, pointies, control characters #
$line =~ s/&/&\;/g;
$htmlcolour = $colour_nick{$nick} = html_rgb($nickcount, $NICKMAX);
}
output_timenicktext($date, $time, $channel, $nick, $text, $htmlcolour);
- }
-
- elsif ($line =~ /^>\;>\;>\; /) {
+ } elsif ($line =~ /^>\;>\;>\; /) {
$line =~ s/^>\;>\;>\; /\*\*\* /;
# Process changed nick results, and remember colours accordingly #
- if ($line =~ /\*\*\* (.*?) are|is now known as (.*)/) {
- my $nick_old;
- my $nick_new;
-
- $nick_old = $line;
- $nick_old =~ s/\*\*\* (.*?) (are|is) now known as .*/$1/;
+ if ($line =~ /\*\*\* (.*?) materializes into (.*)/) {
+ my $nick_old = $1;
+ my $nick_new = $2;
- $nick_new = $line;
- $nick_new =~ s/\*\*\* .*? (are|is) now known as (.*)/$2/;
+ #$nick_old = $line;
+ #$nick_old =~ s/\*\*\* (.*?) materializes into .*/$1/;
+ #$nick_new = $line;
+ #$nick_new =~ s/\*\*\* (.*?) materializes into (.*)/$2/;
$colour_nick{$nick_new} = $colour_nick{$nick_old};
$colour_nick{$nick_old} = undef;
$line =~ s/(\*\*\* .*)/<font color=\"$colour_nickchange\">$1<\/font>/
- }
-
- # Colourise joined/left/server messages #
- elsif ($line =~ /\*\*\* .*left|quit/) {
- $line =~ s/(\*\*\* .*)/<font color=\"$colour_left\">$1<\/font>/;
- }
- elsif ($line =~ /\*\*\* .*joined/) {
+ } elsif ($line =~ /\*\*\* (join|mode|topic)\/(.*?) .*/) {
+ $channel = lc $2;
$line =~ s/(\*\*\* .*)/<font color=\"$colour_joined\">$1<\/font>/;
- }
- elsif ($line =~ /\*\*\* /) {
+ } elsif ($line =~ /\*\*\* (part|kick|banned)\/(.*?) .*/) {
+ $channel = lc $2;
+ $line =~ s/(\*\*\* .*)/<font color=\"$colour_left\">$1<\/font>/;
+ } elsif ($line =~ /\*\*\* .* has signed off IRC .*/) {
+ # Colourise joined/left/server messages #
+ $line =~ s/(\*\*\* .*)/<font color=\"$colour_left\">$1<\/font>/;
+ } elsif ($line =~ /\*\*\* /) {
$line =~ s/(\*\*\* .*)$/<font color=\"$colour_server\">$1<\/font>/;
- }
-
- # Colourise the /me's #
- elsif ($line =~ /^\* .*$/) {
+ } elsif ($line =~ /^\* .*$/) {
+ # Colourise the /me's #
$line =~ s/^(\*.*)$/<font color=\"$colour_action\">$1<\/font>/;
}
- output_timeservermsg($date, $time, $line);
+ output_timeservermsg($date, $time, $channel, $line);
}
}
}
if (!scalar @ARGV) {
print "Usage: irclog2html.pl <date> < logfile\n";
- print "Example: bzcat log/blootbot.log-20021104.bz2 | irclog2html.pl 20021104\n";
+ print "Example: bzcat log/infobot.log-20021104.bz2 | irclog2html.pl 20021104\n";
exit 0;
}
my $date = shift;