Torbjorn Svensson 19 лет назад
Родитель
Сommit
ceedf1b8da
3 измененных файлов с 108 добавлено и 0 удалено
  1. 1 0
      Makefile
  2. 3 0
      docs/Changelog
  3. 104 0
      modules/Pisg/Parser/Format/konversation.pm

+ 1 - 0
Makefile

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

+ 3 - 0
docs/Changelog

@@ -1,6 +1,9 @@
 pisg (0.72) - ??
 pisg (0.72) - ??
     Language Updates:
     Language Updates:
       + Spanish: remove extra quote char (thanks Angel Olivera).
       + Spanish: remove extra quote char (thanks Angel Olivera).
+    Torbjörn:
+    * Parsers:
+      + New parser for Konversation. Thanks ehein for the log.
 
 
 pisg (0.71) - Wed Feb, 14th 2007
 pisg (0.71) - Wed Feb, 14th 2007
    The Valentine's Day Release.
    The Valentine's Day Release.

+ 104 - 0
modules/Pisg/Parser/Format/konversation.pm

@@ -0,0 +1,104 @@
+package Pisg::Parser::Format::konversation;
+
+# 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+)[^\]]+\]\s+<([^>]+)>\s+(.*)$',
+		actionline => '^\[[^\[]+\[(\d+)[^\]]+\]\s+\*\s(\S+)\s(.*)$',
+		thirdline  => '^\[[^\[]+\[(\d+):(\d+)[^\]]+\]\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} = $4;
+
+		if ($4 eq 'You') {
+			# Hack to remove You as a nick
+			$hash{nick} = $self->{cfg}->{maintainer};
+		}
+
+		if ($3 eq 'Mode') {
+			$hash{newmode} = $5;
+			$hash{newmode} =~ s/^[^+-]*//;
+
+		} elsif ($3 eq 'Join') {
+			$hash{newjoin} = $4;
+
+		} elsif ($3 eq 'Nick') {
+			$hash{newnick} = $5;
+			$hash{newnick} =~ s/^.*\s+(\S+)$/$1/;
+
+		} elsif ($3 eq 'Kick') {
+			if ($5 =~ /(\S+) from the channel \((.+)\).$/ ) {
+				$hash{kicker} = $1;
+				$hash{kicktext} = $2;
+			} else {
+				return;
+			}
+
+		} elsif ($3 eq 'Topic') {
+			if ($5 =~ /the channel topic to "(.*)"\.$/) {
+				$hash{newtopic} = $1;
+			} else {
+				return;
+			}
+		
+		}
+		
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;