/[irc-logger]/trunk/bin/irc-logger.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/irc-logger.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Mon Feb 27 11:54:38 2006 UTC revision 5 by dpavlin, Mon Feb 27 12:10:07 2006 UTC
# Line 2  Line 2 
2  use strict;  use strict;
3  $|++;  $|++;
4    
5    =head1 NAME
6    
7    irc-logger.pl
8    
9    =head1 SYNOPSIS
10    
11    ./irc-logger.pl
12    
13    =head1 DESCRIPTION
14    
15    log all conversation on irc channel
16    
17    =cut
18    
19  ## CONFIG  ## CONFIG
20    
21  my $NICK = 'irc-logger';  my $NICK = 'irc-logger';
# Line 19  my %FOLLOWS = Line 33  my %FOLLOWS =
33     ERROR => "/var/log/apache/error.log",     ERROR => "/var/log/apache/error.log",
34    );    );
35    
36    my $DSN = 'DBI:Pg:dbname=irc-logger';
37    
38  ## END CONFIG  ## END CONFIG
39    
40  my $SKIPPING = 0;               # if skipping, how many we've done  
 my $SEND_QUEUE;                 # cache  
41    
42  use POE qw(Component::IRC Wheel::FollowTail);  use POE qw(Component::IRC Wheel::FollowTail);
43    use DBI;
44    
45    
46    my $dbh = DBI->connect($DSN,"","", { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;
47    
48    =for SQL schema
49    
50    $dbh->do(qq{
51    create table log (
52            id serial,
53            time timestamp default now(),
54            channel text not null,
55            nick text not null,
56            message text not null,
57            primary key(id)
58    );
59    
60    create index log_time on log(time);
61    create index log_channel on log(channel);
62    create index log_nick on log(nick);
63    
64    });
65    
66    =cut
67    
68    my $sth = $dbh->prepare(qq{
69    insert into log
70            (channel, nick, message)
71    values (?,?,?)
72    });
73    
74    
75    my $SKIPPING = 0;               # if skipping, how many we've done
76    my $SEND_QUEUE;                 # cache
77    
78  POE::Component::IRC->new($IRC_ALIAS);  POE::Component::IRC->new($IRC_ALIAS);
79    
# Line 47  POE::Session->create Line 96  POE::Session->create
96            my $msg = $_[ARG2];            my $msg = $_[ARG2];
97    
98            print "$channel: <$nick> $msg\n";            print "$channel: <$nick> $msg\n";
99              $sth->execute($channel, $nick, $msg);
100      },      },
101      (map      (map
102       {       {
# Line 56  POE::Session->create Line 106  POE::Session->create
106          connected snotice ctcp_action ping notice mode part quit          connected snotice ctcp_action ping notice mode part quit
107          001 002 003 004 005          001 002 003 004 005
108          250 251 252 253 254 265 266          250 251 252 253 254 265 266
109          332 333 353 366 372 375 376)),          332 333 353 366 372 375 376
110                    477
111                    )),
112      _child => sub {},      _child => sub {},
113      _default => sub {      _default => sub {
114        printf "%s: session %s caught an unhandled %s event.\n",        printf "%s: session %s caught an unhandled %s event.\n",

Legend:
Removed from v.4  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.26