Morten Brix Pedersen 24 лет назад
Родитель
Сommit
b908368d3d
2 измененных файлов с 96 добавлено и 0 удалено
  1. 8 0
      docs/FORMATS
  2. 88 0
      modules/Pisg/Parser/Format/bobot.pm

+ 8 - 0
docs/FORMATS

@@ -135,3 +135,11 @@ link to the logfile)
   Tested with Trillian Version 0.70
 
   - In order to use this, format must be set to 'Trillian'
+
+* bobot++:
+  - IRC bot written in C++. (http://pltplp.net/bobot++/)
+
+  - In order to use this, format must be set to 'bobot'
+
+  Example:
+  [13/12/2001 - 20:38] <NazoZzz> hello world

+ 88 - 0
modules/Pisg/Parser/Format/bobot.pm

@@ -0,0 +1,88 @@
+# package for bobot parsing made by Oct@zoy.org
+package Pisg::Parser::Format::bobot;
+
+# 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 => '^\[[^-]+- ([^:]+):[^\]]+\] <([^>]+)> (.*)$',
+        actionline => '^\[[^-]+- ([^:]+):[^\]]+\] \* ([^ ]+) (.*)$',
+        thirdline  => '^\[[^-]+- ([^:]+):([^\]]+)\] \*\*\* ([^ ]+) \[[^\]]+\] (.*)$',
+    };
+
+    bless($self, $type);
+    return $self;
+}
+
+sub normalline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{normalline}/) {
+
+        $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}/) {
+
+        $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}/) {
+        $hash{hour} = $1;
+        $hash{min}  = $2;
+        $hash{nick} = $3;
+        if($4 =~ /^topic ([^ ]+) \((.*)\)$/)
+	{
+	    $hash{newtopic}= $2;
+	} elsif($4 =~ /^mode ([\+-]o+) (.*)$/)
+	{
+	    $hash{newmode} = $1;
+	    $hash{nick} = $2;
+	} elsif($4 =~/^kick ([^ ]+) .*$/)
+	{
+	    $hash{kicker} = $hash{nick};
+	    $hash{nick} = $1;
+	} elsif($4 =~/^join .*$/)
+	{
+	    $hash{newjoin} = $hash{nick};
+	}
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;