| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package Pisg::Parser::Format::infobot;
- # Documentation for the Pisg::Parser::Format modules is found in Template.pm
- # Note that infobot log files do not distinguish between action lines and
- # normal lines. This parser assumes that people in your channel use correct
- # sentence case for normal lines. YMMV.
- use strict;
- $^W = 1;
- sub new
- {
- my ($type, %args) = @_;
- my $self = {
- cfg => $args{cfg},
- normalline => '^(\d+) \[\d+\] <([^\/]+)\/[^>]+> ([^a-z].*)',
- actionline => '^(\d+) \[\d+\] <([^\/]+)\/[^>]+> ([a-z].*)',
- thirdline => '^(\d+) \[\d+\] >>> (.*)',
- };
- bless($self, $type);
- return $self;
- }
- sub normalline
- {
- my ($self, $line, $lines) = @_;
- my %hash;
- my $sec; my $min; my $hour; my $mday; my $mon; my $year;
- my $wday; my $yday; my $isdst;
- if ($line =~ /$self->{normalline}/o) {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($1);
- $hash{hour} = $hour;
- $hash{nick} = $2;
- $hash{saying} = $3;
- return \%hash;
- } else {
- return;
- }
- }
- sub actionline
- {
- my ($self, $line, $lines) = @_;
- my %hash;
- my $sec; my $min; my $hour; my $mday; my $mon; my $year;
- my $wday; my $yday; my $isdst;
- if ($line =~ /$self->{actionline}/o) {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($1);
- $hash{hour} = $hour;
- $hash{nick} = $2;
- $hash{saying} = $3;
- return \%hash;
- } else {
- return;
- }
- }
- sub thirdline
- {
- my ($self, $line, $lines) = @_;
- my %hash;
- my $sec; my $min; my $hour; my $mday; my $mon; my $year;
- my $wday; my $yday; my $isdst;
- if ($line =~ /$self->{thirdline}/o) {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($1);
- $hash{hour} = $hour;
- $hash{min} = $min;
- if ($2 =~ /^\[1m([^(\[0m)]*)\[0m was kicked off \[1m[^\[]*\[0m by \[1m([^(\[0m)]*)\[0m .*/) {
- $hash{nick} = $1;
- $hash{kicker} = $2;
- } elsif ($2 =~ /^([^(\[1m)]*)\[1m\S* (:?)(.*)\[1m\]\[0m set the topic: (.*)/) {
- $hash{nick} = $1;
- $hash{newtopic} = "$3$2$4";
-
- } elsif ($2 =~ /^mode\/\S* \[\[1m([\+\-]o+) .* by \[1m(\S*)\[0m/) {
- $hash{newmode} = $1;
- $hash{nick} = $2;
-
- } elsif ($2 =~ /^(\S*) \(\S*\) has joined \#\S*/) {
- $hash{newjoin} = $1;
-
- } elsif ($2 =~ /^\[1;32m([^(\[0m)]*)\[0m materializes into \[1;32m([^(\[0m)]*)\[0m/) {
- $hash{nick} = $1;
- $hash{newnick} = $2;
- }
- return \%hash;
- } else {
- return;
- }
- }
- 1;
|