4
0
Эх сурвалжийг харах

Add moobot support, by Phil Gregory

Morten Brix Pedersen 24 жил өмнө
parent
commit
34250c8c65

+ 1 - 0
Makefile

@@ -63,6 +63,7 @@ FORMAT_MODULES = $(MODULESDIR)/Pisg/Parser/Format/axur.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/mbot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/mIRC.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/muh.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/moobot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/perlbot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/pircbot.pm \
 		 $(MODULESDIR)/Pisg/Parser/Format/psybnc.pm \

+ 1 - 0
docs/Changelog

@@ -9,6 +9,7 @@ pisg (x.xx)
    * New 'darkred' colorscheme (thanks, Hanno Hecker)
    * mIRC, Trillian, perlbot and virc98 formats now strips half-op prefixes
      from nicks as well.
+   * moobot logfile support added (thanks, Phil Gregory)
 
 pisg (0.40) - Thu Jul, 4th 2002
    * The "It's Summer And The Sun Is Shining"-release.

+ 25 - 0
docs/FORMATS

@@ -300,3 +300,28 @@ time"
 	[17:25:36] wwp [anonymous@AMontpellier-201-2-1-77.abo.wanadoo.fr] has joined #ECI
 	[17:25:47] <wwp> yop
 	### Log session terminated at Sun Sep 9 22:56:51 2001 ###
+
+* moobot
+  - Python-based, modular IRC bot.  <http://sourceforge.net/projects/moobot>
+
+  - Turn on logging by adding an entry to the data table with type = 'logtype'
+    and data = 'file' or 'date'.  Add another entry with type = 'logfile' and
+    data = the name of the file if type == 'file' or a string to be passed to
+    strftime if type == 'date'.
+
+  - The format name is "moobot".
+
+  - All nicks are logged with their hostmasks, with the exception of those
+    from the bot itself.  (This may change in the future to have the bot's
+    hostmask, too.)
+
+  - Examples:
+
+      2002-07-06 00:05:29 :vergil!~vergil@host PUBMSG #space :mike_lap: i'm not joking, actually.
+      2002-07-04 15:56:19 :SpaceBot PUBMSG #space :huh?
+      2002-07-06 00:07:30 :vergil!~vergil@host CTCP #space :ACTION salutes
+      2002-07-18 10:37:18 :jeffcovey!~jeff@host KICK #space vergil :two days in a row!
+      2002-07-06.log:2002-07-06 12:07:41 :phil_tty!mjpr@host TOPIC #space :<She-Ra> of course, god can go to rotters, for all she's managed not to do for me
+      2002-07-04 17:34:01 :jeffcovey!~jeff@host MODE #space +o CowBot
+      2002-07-04 12:02:42 :Leebert!~lsherida@host JOIN :#space
+      2002-07-04 18:24:18 :mike_lap!~emag@host NICK :Cathy

+ 105 - 0
modules/Pisg/Parser/Format/moobot.pm

@@ -0,0 +1,105 @@
+package Pisg::Parser::Format::moobot;
+
+use strict;
+$^W = 1;
+
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '^\d{4}-\d{2}-\d{2} (\d{2}):\d{2}:\d{2} :([^! ]+)(?:![^ ]+)? PUBMSG ([^ ]+) :(.*)',
+        actionline => '^\d{4}-\d{2}-\d{2} (\d{2}):\d{2}:\d{2} :([^! ]+)(?:![^ ]+)? CTCP ([^ ]+) :ACTION (.*)',
+        thirdline  => '^\d{4}-\d{2}-\d{2} (\d{2}):(\d{2}):\d{2} :([^! ]+)(?:![^ ]+)? ([^ ]+) :?([^ ]+) ?(.*)',
+    };
+
+    bless($self, $type);
+    return $self;
+}
+
+sub normalline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{normalline}/o and
+	$3 eq $self->{cfg}->{channel}) {
+
+        $hash{hour}   = $1;
+        $hash{nick}   = $2;
+        $hash{saying} = $4;
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+sub actionline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{actionline}/o and
+	$3 eq $self->{cfg}->{channel}) {
+
+        $hash{hour}   = $1;
+        $hash{nick}   = $2;
+        $hash{saying} = $4;
+
+        return \%hash;
+    } else {
+        return;
+    }
+}
+
+sub thirdline
+{
+    my ($self, $line, $lines) = @_;
+    my %hash;
+
+    if ($line =~ /$self->{thirdline}/o and
+	$5 eq $self->{cfg}->{channel}) {
+
+	my $args = $6;
+
+        $hash{hour} = $1;
+        $hash{min}  = $2;
+        $hash{nick} = $3;
+
+	if ($4 eq "KICK") {
+	    $hash{kicker} = $3;
+	    $args =~ /^([^ ]+)/;
+	    $hash{nick} = $1;
+
+	} elsif ($4 eq "TOPIC") {
+	    $args =~ s/^://;
+	    $hash{newtopic} = $args;
+
+	} elsif ($4 eq "MODE") {
+	    $hash{newmode} = $args;
+
+	} elsif ($4 eq "JOIN") {
+	    $hash{newjoin} = $3;
+	}
+
+        return \%hash;
+
+    # Nick changes do not have an associated channel.
+    } elsif ($line =~ /$self->{thirdline}/o and
+	     $4 eq "NICK") {
+	
+        $hash{hour}    = $1;
+        $hash{min}     = $2;
+        $hash{nick}    = $3;
+	$hash{newnick} = $5;
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;