Преглед изворни кода

Add virc98 parser by HceZar <hcezar@freemail.it>

Morten Brix Pedersen пре 24 година
родитељ
комит
e3d3855670
2 измењених фајлова са 136 додато и 0 уклоњено
  1. 19 0
      docs/FORMATS
  2. 117 0
      modules/Pisg/Parser/Format/virc98.pm

+ 19 - 0
docs/FORMATS

@@ -232,3 +232,22 @@ link to the logfile)
 
   Example:
   15.57.40 # <elho> hello world! 
+
+* ViRC98:                                                                                      
+  - A client for Windows (http://www.hansprestige.com)                                         
+      at this time is ViRC2.0rc1                                                               
+      maybe the type of logs will change                                                       
+                                                                                               
+    Remember to timestamp your logs, or it wont work,                                          
+    active it checking                                                                         
+    "Client setup/ViRC '98 options/Chat logging/                                               
+     (Miscellaneous logging options)Stamp every message logged with current                    
+time"                                                                                          
+                                                                                               
+  - In order to use this, format must be set to 'virc98'.                                      
+                                                                                               
+  Examples:                                                                                    
+    01.15.39 [Fender]   this is a normal line writen by myself                             
+    00.55.38 <@jax1n0^O>   this is a normal line writen by another                                
+    22.24.27 * Fender says an action                                                  
+

+ 117 - 0
modules/Pisg/Parser/Format/virc98.pm

@@ -0,0 +1,117 @@
+package Pisg::Parser::Format::virc98;
+
+# Documentation for the Pisg::Parser::Format modules is found in Template.pm
+# Parser for MeGALiTH's Visual IRC 98 on IRCnet (nicks lenght 9 chars)
+# by HceZar hcezar@freemail.it
+# Fender @ IRCnet #oristano,#italymania
+
+use strict;
+$^W = 1;
+
+sub new
+{
+    my ($type, %args) = @_;
+    my $self = {
+        cfg => $args{cfg},
+        normalline => '^(\d+)\.\d+[^ ]+ [<\[](.{1,9})[\]>]\s+(.*)',
+        actionline => '^(\d+)\.\d+[^ ]+ \* (\S+) (.*)',
+        thirdline  => '^(\d+)\.(\d+)[^ ]+.* \*\*\* (\S+) (\S+) (\S+) (\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}   = remove_prefix($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}   = remove_prefix($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 (($4.$5) eq 'haskicked') {
+            $hash{kicker} = $3;
+            $hash{nick} = $6;
+		
+        } elsif ($4.$5.$6.$7 eq 'haschangedthetopic') {
+            $hash{nick} = $3;
+            $hash{newtopic} = "$11";
+
+        } elsif (($3.$4) eq 'Modechange') {
+            $hash{newmode} = remove_braces($5);
+            $hash{nick} = $11;
+
+        } elsif (($5.$6) eq 'hasjoined') {
+            $hash{newjoin} = $3;
+            $hash{nick} = $3;
+
+        } elsif (($5.$6) eq 'nowknown') {
+            $hash{newnick} = $8;
+            $hash{nick} = $3;
+        }
+
+        return \%hash;
+
+    } else {
+        return;
+    }
+}
+
+sub remove_prefix
+{
+    my $str = shift;
+    
+    $str =~ s/^@//;
+    $str =~ s/^\+//;
+
+    return $str;
+
+}
+
+sub remove_braces
+{
+    my $str = shift;
+    
+    $str =~ s/^\[//;
+    
+    return $str;
+
+}
+1;