Jelajahi Sumber

* Added support for rbot logs (thanks, Anders Bach Nielsen)

Morten Brix Pedersen 23 tahun lalu
induk
melakukan
55b504e5f2
3 mengubah file dengan 127 tambahan dan 0 penghapusan
  1. 1 0
      docs/Changelog
  2. 16 0
      docs/FORMATS
  3. 110 0
      modules/Pisg/Parser/Format/rbot.pm

+ 1 - 0
docs/Changelog

@@ -1,6 +1,7 @@
 pisg (x.xx)
    * Make the HTML output XHTML compliant again (thanks, Stian Jordet)
    * Add a bullet conversion character to Common.pm (thanks, Stian Jordet)
+   * Added support for rbot logs (thanks, Anders Bach Nielsen)
    * Support for muh2 logs (muh 2.2 and later) (thanks, Sebastian Erlhofer)
    * Add hebrew language translation (thanks, shimi)
    * Add Bulgarian language translation (thanks, m9ck)

+ 16 - 0
docs/FORMATS

@@ -425,3 +425,19 @@ time"
 		[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..."
+
+
+* rbot (http://linuxbrit.co.uk/rbot/)
+  - rbot is a ruby IRC bot. Think of him as a ruby
+    infobot, with more and different features, and a nicer plugin scheme.
+
+  - In order to use this, format must be set to 'rbot'
+
+  Example:
+  [2003/07/22 22:02:59] <Rathnor> well, i'm
+  considering setting up a cronjob or something to watch it
+  [2003/07/22 22:03:11] <ak|ra> hehe
+  [2003/07/22 22:03:24] @ Mode +o Rathnor by ChanServ
+  [2003/07/22 22:03:25] @ Quit: oddbudman: Remote
+  closed the connection
+  [2003/07/22 22:03:29] <FluxBot> Rathnor: :(

+ 110 - 0
modules/Pisg/Parser/Format/rbot.pm

@@ -0,0 +1,110 @@
+package Pisg::Parser::Format::rbot;
+
+# 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+ (\d+):\d+:\d+\] <([^>\s]+)>\s+(.*)',
+        actionline => '\[\d+/\d+/\d+ (\d+):\d+:\d+\] \*{1,}\s+(\S+) (.*)',
+        thirdline  => '\[\d+/\d+/\d+ (\d+):(\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 (($3) eq 'Quit') {
+	    $hash{nick} = $4;
+
+	} elsif (($3) eq 'Mode') {
+	    
+	    if (($4) eq '+o') {
+		$hash{newmode} = '+o';
+		$hash{nick} = $5;
+
+	    } elsif (($4) eq '-o') {
+		$hash{newmode} = '-o';
+		$hash{nick} = $5;
+
+	    } elsif (($4) eq '+v') {
+		$hash{newmode} = '+v';
+		$hash{nick} = $5;
+
+	    } elsif (($4) eq '-v') {
+		$hash{newmode} = '-v';
+		$hash{nick} = $5;
+
+	    }
+		    
+	}elsif (($4.$5) eq 'joinedchannel') {
+	    $hash{nick} = $3;
+	    $hash{newjoin} = $3;
+
+	}elsif (($4.$5) eq 'settopic') {
+	    $hash{newtopic} = $6.$7.$8;
+
+	}elsif (($4.$5.$6.$7) eq 'isnowknownas') {
+	    $hash{nick} = $3;
+	    $hash{newnick} = $8;
+	}
+
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;