]> git.donarmstrong.com Git - infobot.git/blobdiff - scripts/irclog2html.pl
cleanup
[infobot.git] / scripts / irclog2html.pl
index c2affbeeee494e182bc1cec5338ac95e0c0aa81c..b19a1dbd5916887e11466dea00d9448e022db0b0 100755 (executable)
@@ -9,13 +9,13 @@
 # Contributors:
 #   Rick Welykochy <rick@praxis.com.au>
 #   Alexander Else <aelse@uu.net>
+#   Tim Riker <Tim@Rikers.org>
 
 # Released under the terms of the GNU GPL
 # http://www.gnu.org/copyleft/gpl.html
 
 # Modified by Tim Riker <Tim@Rikers.org>
 # to work with infobot logs
-# then modified again for infobot
 
 # Usage: irclog2html <date> < logfile
 
@@ -34,9 +34,9 @@ use POSIX qw(strftime);
 
 # Comment out the "table" assignment to use the plain version
 
-#my $STYLE             =       "tt";
-#my $STYLE             =       "simplett";
-#my $STYLE             =       "table";
+#my $STYLE = "tt";
+#my $STYLE = "simplett";
+#my $STYLE = "table";
 my $STYLE = "simpletable";
 
 my $colour_left       = "#000099";    # nick leaving channel
@@ -62,13 +62,12 @@ sub header {
       qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-       <title>irclog2html for $channel on $date</title>
-       <meta name="generator" content="irclog2html.pl by Jeff Waugh">
-       <meta name="version" content="Version 1.5 - 11th May 2000">
-       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>IRC log for $channel on $date</title>
+ <meta name="generator" content="irclog2html.pl">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 </head>
 <body text="#000000" bgcolor="#ffffff">
-<h1>irclog2html for $channel on $date</h1>
+<h1>IRC log for $channel on $date</h1>
 };
 
     if ( $STYLE =~ /table/ ) {
@@ -84,11 +83,9 @@ sub footer {
     }
 
     $return .= qq{
-<br>Generated by irclog2html.pl by
-<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://infobot.sourceforge.net/">infobot</a> logs, split per channel, etc.
+<br>Generated by irclog2html.pl
+Modified by <a href="http://Rikers.org">Tim Riker</a> to work with
+<a href="http://infobot.sourceforge.net/">infobot</a>.
 </body></html>
 };
     return $return;
@@ -284,14 +281,32 @@ sub main {
                     # new nick
                     $nickcount++;
 
-              # if we've exceeded our estimate of the number of nicks, double it
+                    # if we've exceeded our estimate of the number of nicks, double it
                     $NICKMAX *= 2 if $nickcount >= $NICKMAX;
 
                     $htmlcolour = $colour_nick{$nick} =
                       html_rgb( $nickcount, $NICKMAX );
                 }
-                output_timenicktext( $date, $time, $channel, $nick, $text,
-                    $htmlcolour );
+                output_timenicktext( $date, $time, $channel, $nick, $text, $htmlcolour );
+            }
+            elsif ( $line =~ /^\* ([^ \/]+)\/(\#[^ ]+) (.+)/ ) {
+                # Colourise the /me's #
+                $nick=$1;
+                $channel=$2;
+                $text="<font color=\"$colour_action\">$3</font>";
+                $htmlcolour = $colour_nick{$nick};
+                if ( !defined($htmlcolour) ) {
+
+                    # new nick
+                    $nickcount++;
+
+                    # if we've exceeded our estimate of the number of nicks, double it
+                    $NICKMAX *= 2 if $nickcount >= $NICKMAX;
+
+                    $htmlcolour = $colour_nick{$nick} =
+                      html_rgb( $nickcount, $NICKMAX );
+                }
+                output_timenicktext( $date, $time, $channel, $nick, $text, $htmlcolour );
             }
             elsif ( $line =~ /^&gt\;&gt\;&gt\; / ) {
                 $line =~ s/^&gt\;&gt\;&gt\; /\*\*\* /;
@@ -309,8 +324,7 @@ sub main {
                     $colour_nick{$nick_new} = $colour_nick{$nick_old};
                     $colour_nick{$nick_old} = undef;
 
-                    $line =~
-s/(\*\*\* .*)/<font color=\"$colour_nickchange\">$1<\/font>/;
+                    $line =~ s/(\*\*\* .*)/<font color=\"$colour_nickchange\">$1<\/font>/;
                 }
                 elsif ( $line =~ /\*\*\* (join|mode|topic)\/(.*?) .*/ ) {
                     $channel = lc $2;
@@ -352,7 +366,7 @@ s/(\*\*\* .*)/<font color=\"$colour_nickchange\">$1<\/font>/;
 if ( !scalar @ARGV ) {
     print "Usage: irclog2html.pl <date> < logfile\n";
     print
-      "Example: bzcat log/infobot.log-20021104.bz2 | irclog2html.pl 20021104\n";
+      "Example: bzcat log/2002/1104.bz2 | irclog2html.pl 20021104\n";
     exit 0;
 }
 my $date = shift;