]> jfr.im git - irc/pisg.git/blob - pisg/modules/Pisg/Parser/Format/zcbot.pm
import from cvs
[irc/pisg.git] / pisg / modules / Pisg / Parser / Format / zcbot.pm
1 package Pisg::Parser::Format::zcbot;
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+):[^ ]+ :([^!]+)[^ ]+ PRIVMSG (\#[^ ]+) :([^\001].*)',
14 actionline => '^[^ ]+ (\d+):[^ ]+ :([^!]+)[^ ]+ PRIVMSG (\#[^ ]+) :\001ACTION (.*)',
15 thirdline => '^[^ ]+ (\d+):(\d+):\d+ :([^!]+)[^ ]+ ([A-Z]+) (.*)',
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 && lc($3) eq lc($self->{cfg}->{channel})) {
28
29 $hash{hour} = $1;
30 $hash{nick} = $2;
31 $hash{saying} = $4;
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 && lc($3) eq lc($self->{cfg}->{channel})) {
45
46 $hash{hour} = $1;
47 $hash{nick} = $2;
48 $hash{saying} = $4;
49
50 return \%hash;
51 } else {
52 return;
53 }
54 }
55
56 sub thirdline
57 {
58 my ($self, $line, $lines) = @_;
59 my %hash;
60 my $tmp;
61
62 if ($line =~ /$self->{thirdline}/o) {
63
64 $hash{hour} = $1;
65 $hash{min} = $2;
66 $hash{nick} = $3;
67
68 my @arr = split(" ", $5);
69 if ($4 eq 'KICK' && lc($arr[0]) eq lc($self->{cfg}->{channel})) {
70 $hash{kicker} = $hash{nick};
71 $hash{nick} = $arr[1];
72
73 } elsif ($4 eq 'TOPIC' && lc($arr[0]) eq lc($self->{cfg}->{channel})) {
74 $tmp = join(" ", @arr[1..$#arr]);
75 $tmp =~ s/^://;
76 $hash{newtopic} = $tmp;
77
78 } elsif ($4 eq 'MODE' && lc($arr[0]) eq lc($self->{cfg}->{channel})) {
79 $hash{newmode} = $arr[1];
80
81 } elsif ($4 eq 'JOIN' && lc($arr[0]) eq ":".lc($self->{cfg}->{channel})) {
82 $hash{newjoin} = $3;
83
84 } elsif ($4 eq 'NICK') {
85 $arr[0] =~ s/^://;
86 $hash{newnick} = $arr[0];
87 }
88
89 return \%hash;
90
91 } else {
92 return;
93 }
94 }
95
96 1;