Explorar o código

energymech support by Torsten Karwoth <agonizer@gmx.de>

Morten Brix Pedersen %!s(int64=24) %!d(string=hai) anos
pai
achega
6b123928bd
Modificáronse 1 ficheiros con 91 adicións e 0 borrados
  1. 91 0
      modules/Pisg/Parser/Format/energymech.pm

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

@@ -0,0 +1,91 @@
+package Pisg::Parser::Format::energymech;
+
+# 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+[^ ]+ <([^>]+)> (.*)',
+        actionline => '^\[(\d+):\d+[^ ]+ \* (\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} = $3;
+
+        if (($4.$5) eq 'waskicked') {
+            $hash{kicker} = $7;
+
+        } elsif (($4.$5) eq 'changestopic') {
+            $hash{newtopic} = "$7 $8";
+
+        } elsif (($4.$5) eq 'setsmode:') {
+            $hash{newmode} = $6;
+
+        } elsif ($3 eq 'Joins:') {
+            $hash{nick} = $4;
+            $hash{newjoin} = $4;
+
+        } elsif (($5.$6) eq 'nowknown') {
+            $hash{newnick} = $8;
+        }
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;