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

Add support for HydraIRC (thanks, David Lynch)

Morten Brix Pedersen 23 лет назад
Родитель
Сommit
54143f3476
4 измененных файлов с 113 добавлено и 0 удалено
  1. 1 0
      Makefile
  2. 1 0
      docs/Changelog
  3. 14 0
      docs/FORMATS
  4. 97 0
      modules/Pisg/Parser/Format/hydra.pm

+ 1 - 0
Makefile

@@ -60,6 +60,7 @@ FORMAT_MODULES = $(MODULESDIR)/Pisg/Parser/Format/axur.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/eggdrop.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/energymech.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/grufti.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/hydra.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/ircle.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/infobot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/irssi.pm \

+ 1 - 0
docs/Changelog

@@ -16,6 +16,7 @@ pisg (x.xx)
    * Add config option "NoIgnoredQuotes" - will not output quotes containing
      ignored words if this is set.  Will output a blank line after trying 20
      random quotes if all 20 random quotes were ignored.
+   * Add support for HydraIRC logfiles (thanks, David Lynch)
 
 pisg (0.46) - Tue Feb, 11th 2003
    * Fix serious bug which caused garbled output i "Latest topics" and other

+ 14 - 0
docs/FORMATS

@@ -401,3 +401,17 @@ time"
         01:02.03 >>> join/#channel nick (~user@example.com)
         01:02.03 >>> kick/#channel [nick!~user@example.com] by nick (reason)
         01:02.03 >>> nick_ materializes into nick
+
+* HydraIRC (http://hydrairc.sourceforge.net/)
+  - HydraIRC is an open-source IRC client with an attractive and easy to use
+    interface
+    
+  - In order to use this, format must be set to 'hydra'
+  
+  Example:
+    [2003-02-22 16:49:18] *** Alexander changed topic to wibble
+		[2003-02-22 16:52:29] <Alexander> Sorry about the delay.
+		[2003-02-22 16:52:33] <Eien> Slow.  Waking.  Up.
+		[2003-02-22 16:52:34] *** Melody sets channel #ar-roleplay mode +v Alexander
+		[2003-02-22 16:58:57] *** Kemmy|ZZZ changed nick to Kemayo
+		[2003-02-22 17:03:34] * Alexander stirs Eien's brain.  "Cooooooool..."

+ 97 - 0
modules/Pisg/Parser/Format/hydra.pm

@@ -0,0 +1,97 @@
+package Pisg::Parser::Format::hydra;
+
+use strict;
+$^W = 1;
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '^\[\d+-\d+-\d+ (\d+):\d+:\d+\] <([^>\s]+)> (.*)',
+        actionline => '^\[\d+-\d+-\d+ (\d+):\d+:\d+\] \* (\S+) (.+)',
+        thirdline  => '^\[\d+-\d+-\d+ (\d+):(\d+):\d+\] \*{3} (.+)',
+    };
+
+    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;
+
+        # Format-specific stuff goes here.
+
+        if ($3 =~ /^(\S+) was kicked from (\S+) by (\S+) (.+)/) {
+            $hash{nick} = $1;
+            $hash{kicker} = $3;
+            $hash{kicktext} = $4;
+
+        } elsif ($3 =~ /^(\S+) changed topic to (.+)/) {
+             $hash{nick} = $1;
+             $hash{newtopic} = $2;
+             
+        } elsif ($3 =~ /^(\S+) sets channel \S+ mode (\S+) (.+)/) {
+             $hash{nick} = $1;
+             $hash{newmode} = $2;
+             $hash{modechanges} = $3;
+
+        } elsif ($3 =~ /^(\S+) \S+ has joined channel \S+/) {
+            $hash{nick} = $1;
+            $hash{newjoin} = $1;
+
+        } elsif ($3 =~ /^(\S+) changed nick to (\S+)/) {
+            $hash{nick} = $1;
+            $hash{newnick} = $2;
+        }
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;