Morten Brix Pedersen 24 лет назад
Родитель
Сommit
847fbbe767
4 измененных файлов с 150 добавлено и 1 удалено
  1. 3 0
      docs/Changelog
  2. 21 0
      docs/FORMATS
  3. 2 1
      modules/Pisg.pm
  4. 124 0
      modules/Pisg/Parser/Format/ircII.pm

+ 3 - 0
docs/Changelog

@@ -1,3 +1,6 @@
+pisg (x.xx)
+   * ircII logfile support added (thanks, James Andrewartha)
+
 pisg (0.41) - Sun Aug, 11th 2002
    * Fix a bug in the winbot logfile format where lines containing the channel
      name in a wrong case wouldn't get counted.

+ 21 - 0
docs/FORMATS

@@ -325,3 +325,24 @@ time"
       2002-07-04 17:34:01 :jeffcovey!~jeff@host MODE #space +o CowBot
       2002-07-04 12:02:42 :Leebert!~lsherida@host JOIN :#space
       2002-07-04 18:24:18 :mike_lap!~emag@host NICK :Cathy
+
+* ircII
+  - The original IRC client (http://www.eterna.com.au/ircii/)
+
+  - In order to use this, format must be set to 'ircII'
+
+  - You need to add a few on triggers to your .ircrc:
+    on #^timer 50 "*0" echo $0
+    on #^timer 50 "*5" echo $0
+    to mark the time. They can be adjusted to taste (the above lines mark every
+    5 minutes), with the main effect being the topic change times will only
+    accurate to how often the time is marked.
+
+  - The config option "ircIINick" needs to be set to the maintainer's nick
+
+  Example:
+    22:40
+    *** sonnlich (sonnloki@202.72.122.25348) has joined channel #unisfa
+    * sonnlich waves.
+    > evening rae
+    <sonnlich> Evening.

+ 2 - 1
modules/Pisg.pm

@@ -174,6 +174,7 @@ sub get_default_config_settings
         mostnickshistory => 5,
         nicktracking => 0,
         charset => 'iso-8859-1',
+        irciinick => 'maintainer',
 
         # sorting
         sortbywords => 0,
@@ -186,7 +187,7 @@ sub get_default_config_settings
         tablewidth => 614,
         regexpaliases => 0,
 
-        version => "0.41",
+        version => "0.42-cvs",
     };
 
     # Backwards compatibility with old option names:

+ 124 - 0
modules/Pisg/Parser/Format/ircII.pm

@@ -0,0 +1,124 @@
+package Pisg::Parser::Format::ircII;
+
+# Documentation for the Pisg::Parser::Format modules is found in Template.pm
+# Parser for logs from ircII
+# by James Andrewartha <trs80@tartarus.uwa.edu.au>
+# based on Template.pm and Trillian.pm
+
+# Note that you will need some triggers similar to these in your .ircrc to get
+# timestamping:
+# on #^timer 50 "*0" echo $0
+# on #^timer 50 "*5" echo $0
+
+# Known issues: the time of topic changes is only as accurate as the time-
+# stamping (the above lines provide 5-minute accuracy).
+
+use strict;
+$^W = 1;
+
+# Yes, global variables are bad. But they do need to be global to avoid pain.
+my ($global_hour, $global_minute);
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '^(<([^>]+)> (.*)|> (.*))',
+        actionline => '^\* (\S+[^>]) (.*)',
+        thirdline  => '^((\d+):(\d+)|\*{3} (.+)|IRC log started \w+ \w+ \w+ (\d+:\d+))',
+    };
+
+    bless($self, $type);
+    return $self;
+}
+
+# Parse a normal line - returns a hash with 'hour', 'nick' and 'saying'
+sub normalline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{normalline}/o) {
+        $hash{hour}   = $global_hour;
+
+        if ($1 =~ /^<([^>]+)> (.*)/) {
+            $hash{nick}   = $1;
+            $hash{saying} = $2;
+        } elsif ($1 =~ /^> (.*)/) {
+            $hash{nick} = $self->{cfg}->{irciinick};
+            $hash{saying} = $1;
+        }
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+# Parse an action line - returns a hash with 'hour', 'nick' and 'saying'
+sub actionline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{actionline}/o) {
+
+        $hash{hour}   = $global_hour;
+        $hash{nick}   = $1;
+        $hash{saying} = $2;
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+sub thirdline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{thirdline}/o) {
+
+	    # Mainly stolen from Trillian.pm
+        if ($1 =~ /^\*{3} (\S+) has been kicked off channel (\S+) by (\S+) .+/) {
+            $hash{nick} = $1;
+            $hash{kicker} = $3;
+
+        } elsif ($1 =~ /^\*{3} (\S+) has changed the topic on channel (\S+) to (.+)/) {
+             $hash{nick} = $1;
+             $hash{newtopic} = $3;
+
+        } elsif ($1 =~ /^\*{3} Mode change \"(\S+)[^\"]+\".+ by (.+)$/) {
+             $hash{nick} = $2;
+             $hash{newmode} = $1;
+
+        } elsif ($1 =~ /^\*{3} (\S+) \S+ has joined channel \S+/) {
+            $hash{nick} = $1;
+            $hash{newjoin} = $1;
+
+        } elsif ($1 =~ /^\*{3} (\S+) is now known as (\S+)/) {
+            $hash{nick} = $1;
+            $hash{newnick} = $2;
+
+        } elsif ($1 =~ /^(\d+):(\d+)$/) {
+            $global_hour = $1;
+            $global_minute = $2;
+
+        } elsif ($1 =~ /^IRC log started \w+ \w+ \w+ (\d+):(\d+)/) {
+            $global_hour = $1;
+            $global_minute = $2;
+        }
+
+        $hash{hour} = $global_hour;
+        $hash{min}  = $global_minute;
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;