/[irc-logger]/trunk/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/irc-logger.pl

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

revision 13 by dpavlin, Sun Mar 12 14:19:00 2006 UTC revision 14 by dpavlin, Sun Mar 12 14:36:12 2006 UTC
# Line 18  log all conversation on irc channel Line 18  log all conversation on irc channel
18    
19  ## CONFIG  ## CONFIG
20    
21  my $NICK = 'irc-logger-dev';  my $NICK = 'irc-logger';
22  my $CONNECT =  my $CONNECT =
23    {Server => 'irc.freenode.net',    {Server => 'irc.freenode.net',
24     Nick => $NICK,     Nick => $NICK,
# Line 35  my %FOLLOWS = Line 35  my %FOLLOWS =
35    
36  my $DSN = 'DBI:Pg:dbname=irc-logger';  my $DSN = 'DBI:Pg:dbname=irc-logger';
37    
38    my $ENCODING = 'ISO-8859-2';
39    
40  ## END CONFIG  ## END CONFIG
41    
42    
# Line 196  POE::Session->create Line 198  POE::Session->create
198                  my $channel = $_[ARG1]->[0];                  my $channel = $_[ARG1]->[0];
199                  my $msg = $_[ARG2];                  my $msg = $_[ARG2];
200    
201                  from_to($msg, 'UTF-8', 'ISO-8859-2');                  from_to($msg, 'UTF-8', $ENCODING);
202    
203                  print "$channel: <$nick> $msg\n";                  print "$channel: <$nick> $msg\n";
204                  $sth->execute($channel, $nick, $msg);                  $sth->execute($channel, $nick, $msg);
# Line 205  POE::Session->create Line 207  POE::Session->create
207                  my $kernel = $_[KERNEL];                  my $kernel = $_[KERNEL];
208                  my $nick = (split /!/, $_[ARG0])[0];                  my $nick = (split /!/, $_[ARG0])[0];
209                  my $msg = $_[ARG2];                  my $msg = $_[ARG2];
210                  from_to($msg, 'UTF-8', 'ISO-8859-2');                  from_to($msg, 'UTF-8', $ENCODING);
211    
212                  my $res = "unknown command '$msg', try /msg $NICK help!";                  my $res = "unknown command '$msg', try /msg $NICK help!";
213                  my @out;                  my @out;
# Line 240  POE::Session->create Line 242  POE::Session->create
242    
243                          foreach my $res (get_from_log( limit => $1 )) {                          foreach my $res (get_from_log( limit => $1 )) {
244                                  print "last: $res\n";                                  print "last: $res\n";
245                                  from_to($res, 'ISO-8859-2', 'UTF-8');                                  from_to($res, $ENCODING, 'UTF-8');
246                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
247                          }                          }
248    
# Line 252  POE::Session->create Line 254  POE::Session->create
254    
255                          foreach my $res (get_from_log( limit => 20, search => "%${what}%" )) {                          foreach my $res (get_from_log( limit => 20, search => "%${what}%" )) {
256                                  print "search [$what]: $res\n";                                  print "search [$what]: $res\n";
257                                  from_to($res, 'ISO-8859-2', 'UTF-8');                                  from_to($res, $ENCODING, 'UTF-8');
258                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
259                          }                          }
260    
# Line 262  POE::Session->create Line 264  POE::Session->create
264    
265                  if ($res) {                  if ($res) {
266                          print ">> [$nick] $res\n";                          print ">> [$nick] $res\n";
267                          from_to($res, 'ISO-8859-2', 'UTF-8');                          from_to($res, $ENCODING, 'UTF-8');
268                          $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );                          $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
269                  }                  }
270    
# Line 378  POE::Session->create Line 380  POE::Session->create
380  # http server  # http server
381    
382  my $httpd = POE::Component::Server::HTTP->new(  my $httpd = POE::Component::Server::HTTP->new(
383          Port => 8000,          Port => $NICK =~ m/-dev/ ? 8001 : 8000,
384          ContentHandler => { '/' => \&root_handler },          ContentHandler => { '/' => \&root_handler },
385          Headers        => { Server => 'irc-logger' },          Headers        => { Server => 'irc-logger' },
386  );  );
# Line 392  _END_OF_STYLE_ Line 394  _END_OF_STYLE_
394  sub root_handler {  sub root_handler {
395          my ($request, $response) = @_;          my ($request, $response) = @_;
396          $response->code(RC_OK);          $response->code(RC_OK);
397          $response->content_type('text/html');          $response->content_type("text/html; charset=$ENCODING");
398          $response->content(          $response->content(
399                  qq{<html><head><title>$NICK</title><style type="text/css">$style</style></head><body>} .                  qq{<html><head><title>$NICK</title><style type="text/css">$style</style></head><body>} .
400                  "irc-logger url: " . $request->uri . '<br/>' .                  "irc-logger url: " . $request->uri . '<br/>' .

Legend:
Removed from v.13  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26