Christoph Berg 21 лет назад
Родитель
Сommit
d75c21ff48
5 измененных файлов с 114 добавлено и 0 удалено
  1. 1 0
      Makefile
  2. 2 0
      docs/CREDITS
  3. 3 0
      docs/Changelog
  4. 9 0
      docs/FORMATS
  5. 99 0
      modules/Pisg/Parser/Format/lulubot.pm

+ 1 - 0
Makefile

@@ -70,6 +70,7 @@ FORMAT_MODULES = $(MODULESDIR)/Pisg/Parser/Format/axur.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/ircII.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/javabot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/kvirc.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/lulubot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/oer.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/mbot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/mIRC.pm \

+ 2 - 0
docs/CREDITS

@@ -112,6 +112,8 @@ Other contributors:
    | ShowFoulDecimals option
  * coaster
    | improved mirc6hack.mrc
+ * Vianney Lecroart <acemtp@free.fr>
+   | lulubot parser
 
 I probably forgot a lot of people here, _PLEASE_ notify me if I left you
 out.. because I have a bad habit of forgetting to maintain this list :)

+ 3 - 0
docs/Changelog

@@ -6,6 +6,9 @@ pisg (0.62) - ??
      (required quite some black regexp magic; SF tracker #1066103 by jjp3).
    * wordlist_regexp uses quotemeta.
    * New ShowActiveNicks option (defaulting to 1).
+   * Added lulubot parser (thanks, Vianney Lecroart).
+   Changes by Morten Brix Pedersen:
+   * Fixed typo in French translation.
 
 pisg (0.61) - Sat Oct, 30th 2004
    Changes by Christoph Berg:

+ 9 - 0
docs/FORMATS

@@ -502,3 +502,12 @@ preferences you
      maj 07 21:12:02 ---     CreoN sets mode +o scalldog
      maj 07 21:12:05 <--     CreoN has kicked JavaBot (JavaBot)
      maj 07 21:12:06 -->     JavaBot (~javabot@host.com) has joined #channel
+
+* lulubot
+  - http://lulubot.berlios.de
+  - Version tested with the CVS the 12/04/04
+  - Log format :
+[22-11-2004/14:42] *** Joined ace (~ace@154.25.145.85)
+[22-11-2004/15:00] <ace> morning
+[22-11-2004/15:01] * ace is back
+  - Parser written by Vianney Lecroart <acemtp@free.fr>

+ 99 - 0
modules/Pisg/Parser/Format/lulubot.pm

@@ -0,0 +1,99 @@
+# This is the lulubot log parser by Vianney Lecroart <acemtp@free.fr>
+# More info about lulubot here: http://lulubot.berlios.de and
+# here: http://developer.berlios.de/projects/lulubot
+# Version tested with the CVS the 12/04/04
+
+# [22-11-2004/14:42] *** Joined ace (~ace@154.25.145.85)
+# [22-11-2004/15:00] <ace> morning
+# [22-11-2004/15:01] * ace is back
+
+package Pisg::Parser::Format::lulubot;
+
+use strict;
+$^W = 1;
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '^\[[^/]+/(\d+):\d+\] <([^>]+)> (.*)$',
+        actionline => '^\[[^/]+/(\d+):\d+\] \* (\S+) (.*)$',
+        thirdline  => '^\[[^/]+/(\d+):(\d+)\] \*{3} (\S+) (\S+) (.*)$',
+    };
+
+    bless($self, $type);
+    return $self;
+}
+
+sub normalline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{normalline}/o) {
+
+        # Most log formats are regular enough that you can just match the
+        # appropriate things with parentheses in the regular expression.
+
+        $hash{hour}   = $1;
+        $hash{nick}   = $2;
+        $hash{saying} = $3;
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+sub actionline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{actionline}/o) {
+
+        # Most log formats are regular enough that you can just match the
+        # appropriate things with parentheses in the regular expression.
+
+        $hash{hour}   = $1;
+        $hash{nick}   = $2;
+        $hash{saying} = $3;
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+sub thirdline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{thirdline}/o) {
+
+        $hash{hour} = $1;
+        $hash{min}  = $2;
+        $hash{nick} = $3;
+
+        # Format-specific stuff goes here.
+
+        if ($3 eq 'Joined') {
+            $hash{newjoin} = $4;
+            $hash{nick} = $3;
+        } elsif ($4 eq 'changed') {
+            $5 =~ /^topic to (.*)$/;
+            $hash{newtopic} = $1;
+        } elsif ($4 eq 'is') {
+            $5 =~ /^now known as (.*)$/;
+            $hash{newnick} = $1;
+        }
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+1;