Просмотр исходного кода

Update the dircproxy parser to support both 1.0.5 and 1.1.0 log formats.
Minor update of Swedish translation.

Torbjorn Svensson 20 лет назад
Родитель
Сommit
37b03facb2
4 измененных файлов с 63 добавлено и 33 удалено
  1. 4 0
      docs/Changelog
  2. 2 0
      docs/FORMATS
  3. 1 1
      lang.txt
  4. 56 32
      modules/Pisg/Parser/Format/dircproxy.pm

+ 4 - 0
docs/Changelog

@@ -33,6 +33,9 @@ pisg (0.69) - ??
      + Fix -cchannels option (SF #1369457).
    * Features:
      + Add "+CVS" to versionstring if ./CVS is found
+   * Parsers:
+     + Add support for both the 1.0.5(stable) and the 1.1.0(devel) log format 
+       of dircproxy.
    Language Updates:
      + Portuguese: completed by DarkForce72.
      + Portuguese/Brazil: completed by Guilherme Barile.
@@ -52,6 +55,7 @@ pisg (0.69) - ??
      + Slovenian: completed by HeadRoom.
      + French: updated by pam_.
      + Albanian: completed by Elian.
+     + Swedish: minor update.
 
 pisg (0.68) - Mon Mar, 13th 2006
    Christoph:

+ 2 - 0
docs/FORMATS

@@ -433,6 +433,8 @@ time"
   - Currently does not recognize nick changes - apparently it logs nick changes
     to a separate file.  As a result, nick tracking will not work.
 
+  - This parser recognize both the 1.0.5 and the 1.1.0 log format.
+
  * blootbot (http://blootbot.sourceforge.net/)
   - supports multiple channels, though the log will be parsed once for each
     channel

+ 1 - 1
lang.txt

@@ -1583,7 +1583,7 @@ mostdevoice2 = "<b>[:nick]</b> var inte heller sn
 mostdevoice3 = "Ingen blev av med sin voicestatus i [:channel]!"
 
 mosthalfop1 = "<b>[:nick]</b> gav [:halfops] halvoperatörsstatus i kanalen..."
-mosthalfop2 = "<b>[:nick]</b> var också väldigt snäll: [:halfops] halvoperatörsstatus från [:him:her:]."
+mosthalfop2 = "<b>[:nick]</b> var också väldigt snäll: [:halfops] halvoperatörsstatus från [:honom:henne:]."
 mosthalfop3 = "Konstigt, inga halvoperatörer i [:channel]!"
 
 mostdehalfop1 = "<b>[:nick]</b> är kanalens sheriff och tog ifrån [:dehalfops] deras halvoperatörsstatus."

+ 56 - 32
modules/Pisg/Parser/Format/dircproxy.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::Format::dircproxy;
+package Pisg::Parser::Format::dircproxy2;
 
 # Documentation for the Pisg::Parser::Format modules is found in Template.pm
 
@@ -10,10 +10,13 @@ sub new
     my ($type, %args) = @_;
 
     my $self = {
-        cfg => $args{cfg},
-	normalline => '^<([^!]+)![^>]+>\s\[(\d{2}):\d{2}\]\s(.+)$',
-        actionline => '^\[([^!]+)![^\]]+\]\s\[(\d{2}):\d{2}\]\sACTION\s(.+)$',
-	thirdline  => '^\-(\S+)\-\s\[(\d{2}:\d{2})\]\s(.+)$'
+        cfg             => $args{cfg},
+        normalline      => '^<([^!]+)![^>]+>\s\[(\d{2}):\d{2}\]\s(.+)$',
+        actionline      => '^\[([^!]+)![^\]]+\]\s\[(\d{2}):\d{2}\]\sACTION\s(.+)$',
+        thirdline       => '^\-(\S+)\-\s\[(\d{2}:\d{2})\]\s(.+)$',
+        normalline_old  => '^@(\d+)\s<([^!]+)![^>]+>\s(.+)$',
+        actionline_old  => '^@(\d+)\s\[([^!]+)![^\]]+\]\sACTION\s(.+)$',
+        thirdline_old   => '^@(\d+)\s\S+\s(.+)$'
     };
 
     bless($self, $type);
@@ -30,6 +33,12 @@ sub normalline
         $hash{nick}   = $1;
         $hash{saying} = $3;
 
+        return \%hash;
+    } elsif ($line =~ /$self->{normalline_old}/o) {
+        $hash{hour}   = (localtime($1))[2];
+        $hash{nick}   = $2;
+        $hash{saying} = $3;
+
         return \%hash;
     } else {
         return;
@@ -46,6 +55,12 @@ sub actionline
         $hash{nick}   = $1;
         $hash{saying} = $3;
 
+        return \%hash;
+    } elsif ($line =~ /$self->{actionline_old}/o) {
+        $hash{hour}   = (localtime($1))[2];
+        $hash{nick}   = $2;
+        $hash{saying} = $3;
+
         return \%hash;
     } else {
         return;
@@ -56,49 +71,58 @@ sub thirdline
 {
     my ($self, $line, $lines) = @_;
     my %hash;
+    my @word;
 
     if ($line =~ /$self->{thirdline}/o) {
-        my ($time, @line);
-
-        return
-            if ($1 eq 'dircproxy');
+        return if ($1 eq 'dircproxy');
 
-        @line = split(/\s+/, $3);
+        @word = split(/\s+/, $3);
 
         my @time = split(/:/, $2);
         $hash{hour} = $time[0];
         $hash{min} = $time[1];
-        $hash{nick} = $line[0];
 
-        if (defined($line[3]) && $line[0] eq 'Kicked') {
-            $hash{kicker} = $line[3];
-            $hash{nick} = $self->{cfg}->{maintainer};
+    } elsif ($line =~ /$self->{thirdline_old}/o) {
+        return if ($1 eq 'dircproxy');
 
-        } elsif (defined($line[4]) && $line[1] eq 'kicked') {
-            $hash{kicker} = $line[4];
+        @word = split(/\s+/, $2);
 
-        } elsif (defined($line[3]) && $line[2] eq 'changed') {
-            if ($line[3] eq 'mode:') {
-                $hash{newmode} = join(' ', @line[4..$#line]);
-            } elsif ($line[3] eq 'topic:') {
-                $hash{newtopic} = join(' ', @line[4..$#line]);
-            }
+        $hash{hour} = (localtime($1))[2];
+        $hash{min} = (localtime($1))[1];
 
-        } elsif (defined($line[2]) && $line[2] eq 'joined') {
-            $hash{newjoin} = $hash{nick};
+    } else {
+        return;
+    }
 
-        }
-        # elsif ($line[0] eq 'NICK') {
-        #    $hash{newnick} = $line[1];
-        #    $hash{newnick} =~ s/^://;
-        #}
 
+    # the real parser here for thirdline...
+    $hash{nick} = $word[0];
+    
+    if (defined($word[3]) && $word[0] eq 'Kicked') {
+        $hash{kicker} = $word[3];
+        $hash{nick} = $self->{cfg}->{maintainer};
 
-        return \%hash;
+    } elsif (defined($word[4]) && $word[1] eq 'kicked') {
+        $hash{kicker} = $word[4];
+
+    } elsif (defined($word[3]) && $word[2] eq 'changed') {
+        if ($word[3] eq 'mode:') {
+            $hash{newmode} = join(' ', @word[4..$#word]);
+        } elsif ($word[3] eq 'topic:') {
+            $hash{newtopic} = join(' ', @word[4..$#word]);
+        }
+
+    } elsif (defined($word[2]) && $word[2] eq 'joined') {
+        $hash{newjoin} = $hash{nick};
 
-    } else {
-        return;
     }
+    # elsif ($word[0] eq 'NICK') {
+    #    $hash{newnick} = $word[1];
+    #    $hash{newnick} =~ s/^://;
+    #}
+
+
+    return \%hash;
 }
 
 1;