Przeglądaj źródła

Add javabot logfile support

Morten Brix Pedersen 22 lat temu
rodzic
commit
7f387d00b4
3 zmienionych plików z 95 dodań i 0 usunięć
  1. 1 0
      Makefile
  2. 3 0
      docs/Changelog
  3. 91 0
      modules/Pisg/Parser/Format/javabot.pm

+ 1 - 0
Makefile

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

+ 3 - 0
docs/Changelog

@@ -1,3 +1,6 @@
+pisg (x.xx)
+   * Added javabot support (thanks, Tobias Larsson)
+
 pisg (0.54) - Thu Apr, 1st 2004
    * Revert most of the performance improvement changes, they caused bugs.
    * Really fix topics with the mbot format.

+ 91 - 0
modules/Pisg/Parser/Format/javabot.pm

@@ -0,0 +1,91 @@
+package Pisg::Parser::Format::javabot;
+
+# Documentation for the Pisg::Parser::Format modules is found in Template.pm
+
+use strict;
+$^W = 1;
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '(\d+):\d+:\d+ <([^>\s]+)>\s+(.*)',
+        actionline => '(\d+):\d+:\d+ \*{1,}\s+(\S+) (.*)',
+        thirdline  => '(\d+):(\d+):\d+ [<-]-[->]\s+(\S+) (\S+) (\S+) (\S+) (\S+) ?(\S+)? ?(.*)?',
+    };
+
+    bless($self, $type);
+    return $self;
+}
+
+sub normalline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{normalline}/o) {
+
+        $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) {
+
+        $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;
+
+        if (($4.$5) eq 'haskicked') {
+            $hash{kicker} = $3;
+            $hash{nick} = $6;
+
+        } elsif (($4.$5) eq 'haschanged') {
+            $hash{newtopic} = $9;
+
+        } elsif (($4.$5) eq 'setsmode') {
+            $hash{newmode} = $6;
+
+        } elsif (($5.$6) eq 'hasjoined') {
+            $hash{newjoin} = $1;
+
+        } elsif (($5.$6) eq 'isknown') {
+            $hash{newnick} = $8;
+	}
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;