浏览代码

Added support for sirc format logfiles (thanks bartko)

sbingner 23 年之前
父节点
当前提交
8026139ae8
共有 4 个文件被更改,包括 161 次插入0 次删除
  1. 1 0
      docs/Changelog
  2. 9 0
      docs/FORMATS
  3. 125 0
      modules/Pisg/Parser/Format/sirc.pm
  4. 26 0
      scripts/sirc-timestamp.pl

+ 1 - 0
docs/Changelog

@@ -12,6 +12,7 @@ pisg (x.xx)
      URL's (new config option)
    * Fix bug in mIRC6 format where it didn't recognize logfiles logging seconds
    * Fix bug in mIRC6 format where it didn't recognize kicks of the maintainer
+   * Add support for sirc format (thanks bartko)
 
 pisg (0.44) - Sun Dec, 15th 2002
    * Fixed an error in the mIRC6 format which caused pisg to abort on some

+ 9 - 0
docs/FORMATS

@@ -369,3 +369,12 @@ time"
 
   Example:
     <set botnicks="bot1 bot2 MainBot">
+
+
+* sirc
+  - Simple IRC Client (http://www.iagora.com/~espel/sirc.html)
+
+  - In order to use this, format must be set to 'sirc'
+
+  - You must also load the sirc-timestamp.pl script in the scripts subdirectory
+    into sirc (/load sirc-timestamp.pl after copying to appropriate location)

+ 125 - 0
modules/Pisg/Parser/Format/sirc.pm

@@ -0,0 +1,125 @@
+package Pisg::Parser::Format::sirc;
+
+# Documentation for the Pisg::Parser::Format modules is found in Template.pm
+# parser for logs from sirc
+# based on module by bartko <bartek09@netscape.net>
+
+# the timestamps are needed for statistics generation
+# for timestamping use the timestep script for sirc
+# included in scripts/sirc-timestamp.pl
+
+use strict;
+$^W = 1;
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '(\d+):\d+ <([^>\s]+)>\s+(.*)',
+        actionline => '(\d+):\d+ \* (\S+) (.*)',
+        thirdline  => '(\d+):(\d+) \*(.)\* (.*)',
+    };
+
+    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;
+
+        if ($3 eq '>') {
+            if ($4 =~ /^(\S+) \S+ has joined channel \S+$/) {
+                $hash{newjoin} = $1;
+	        $hash{nick} = $1;
+            } elsif ($4 =~ /^You have joined channel \S+$/) {
+                $hash{newjoin} = $self->{cfg}->{maintainer};
+	        $hash{nick} = $self->{cfg}->{maintainer};
+            }
+
+        } elsif ($3 eq '<') {
+            if ($4 =~ /^(\S+) has been kicked off channel \S+ by (\S+) \((.*)\)$/) {
+                $hash{kicker} = $2;
+                $hash{nick} = $1;
+                $hash{kicktext} = $3;
+            } elsif ($4 =~ /^You have been kicked off channel \S+ by (\S+)/) {
+                $hash{kicker} = $1;
+                $hash{nick} = $self->{cfg}->{maintainer};
+                $hash{kicktext} = $2;
+            }
+
+        } elsif ($3 eq 'T') {
+            if ($4 =~ /^(\S+) has changed the topic on channel \S+ to \"(.+)\"$/) {
+                $hash{newtopic} = $2;
+                $hash{nick} = $1;
+            } elsif ($4 =~ /^You have changed the topic on channel \S+ to \"(.+)\"$/) {
+                $hash{newtopic} = $1;
+                $hash{nick} = $self->{cfg}->{maintainer};
+            } elsif ($4 =~ /^Topic for \S+: (.+)$/) {
+                $self->{topic_temp} = $1;
+            } elsif ($self->{topic_temp} && ($4 =~ /^Topic for \S+ set by ([^!]+)!\S+/)) {
+                $hash{nick} = $1;
+                $hash{newtopic} = $self->{topic_temp};
+                delete $self->{topic_temp};
+            }
+
+        } elsif ($3 eq '+' && ($4 =~ /^Mode change \"(\S+) ([^\"]+)\" on channel \S+ by (\S+)/)) {
+           $hash{newmode} = $1;
+           $hash{modechanges} = $2;
+	   $hash{nick} = $3;
+
+        } elsif ($3 eq 'N' && ($4 =~ /^(S+) is now known as (S+)$/)) {
+            $hash{nick} = $1;
+            $hash{newnick} = $2;
+
+        }
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+1;

+ 26 - 0
scripts/sirc-timestamp.pl

@@ -0,0 +1,26 @@
+# sirc-timestamp.pl
+# script for sirc irc client  which shows time in every line
+# by bartko!misiopysio09@netscape.net
+# http://mywebpage.netscape.com/bartek09/
+
+$add_ons.="+sirc-timestamp.pl";
+
+sub whattime {
+   ($sec,$min,$hour) = localtime(time);
+   ($min < 10) && ($min = "0" . $min);
+   ($hour < 10) && ($hour = "0" . $hour);
+   return "$hour:$min";
+}
+ 
+sub hook_timeprint {
+  my ($theline) = $_[0];
+  $_[0] = whattime() . ' ' . $theline;
+}
+addhook ('print','timeprint');
+
+&addhelp("timestamp","This is \cusirc-timestamp.pl\cu for sirc by \cbbartko\cb
+
+The script adds timestamps in format hh:mm at the
+beginning of each line");
+
+print("*\cba\cb* \cbbartko\cb's \cvsirc-timestamp.pl\cv loaded ... \n");