]> jfr.im git - irc/pisg.git/blob - pisg/modules/Pisg/Parser/Format/psybnc.pm
import from cvs
[irc/pisg.git] / pisg / modules / Pisg / Parser / Format / psybnc.pm
1 package Pisg::Parser::Format::psybnc;
2
3 # Documentation for the Pisg::Parser::Format modules is found in Template.pm
4
5 use strict;
6 $^W = 1;
7
8 sub new
9 {
10 my ($type, %args) = @_;
11 my $self = {
12 cfg => $args{cfg},
13 normalline => '^\d+-\d+-\d+-(\d+)-\d+-\d+:[^:]+::([^!]+)[^:]+ PRIVMSG [^:]+:([^\001]+)',
14 actionline => '^\d+-\d+-\d+-(\d+)-\d+-\d+:[^:]+::([^!]+)[^:]+:\001ACTION ([^\001]*)',
15 thirdline => '^\d+-\d+-\d+-(\d+)-(\d+)-\d+:[^:]+::([^! .]+)[^ ]* (\w+) \S+ :?((\S*)\s*(.*))',
16 };
17
18 bless($self, $type);
19 return $self;
20 }
21
22 sub normalline
23 {
24 my ($self, $line, $lines) = @_;
25 my %hash;
26
27 if ($line =~ /$self->{normalline}/o) {
28
29 $hash{hour} = $1;
30 $hash{nick} = $2;
31 $hash{saying} = $3;
32
33 return \%hash;
34 } else {
35 return;
36 }
37 }
38
39 sub actionline
40 {
41 my ($self, $line, $lines) = @_;
42 my %hash;
43
44 if ($line =~ /$self->{actionline}/o) {
45
46 $hash{hour} = $1;
47 $hash{nick} = $2;
48 $hash{saying} = $3;
49
50 return \%hash;
51 } else {
52 return;
53 }
54 }
55
56 sub thirdline
57 {
58 my ($self, $line, $lines) = @_;
59 my %hash;
60
61 if ($line =~ /$self->{thirdline}/o) {
62
63 $hash{hour} = $1;
64 $hash{min} = $2;
65 $hash{nick} = $3;
66
67 if ($4 eq 'KICK') {
68 $hash{kicker} = $hash{nick};
69 $hash{nick} = $6;
70
71 } elsif ($4 eq 'TOPIC') {
72 $hash{newtopic} = $5;
73
74 } elsif ($4 eq 'MODE') {
75 $hash{newmode} = $6;
76
77 } elsif ($4 eq 'JOIN') {
78 $hash{newjoin} = $3;
79
80 } elsif ($4 eq 'NICK') { # does this work?
81 $hash{newnick} = $6;
82 }
83
84 return \%hash;
85
86 } else {
87 return;
88 }
89 }
90
91 1;