/[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 53 by dpavlin, Sun Mar 18 17:00:16 2007 UTC revision 63 by dpavlin, Fri Jun 8 12:07:45 2007 UTC
# Line 73  use POSIX qw/strftime/; Line 73  use POSIX qw/strftime/;
73  use HTML::CalendarMonthSimple;  use HTML::CalendarMonthSimple;
74  use Getopt::Long;  use Getopt::Long;
75  use DateTime;  use DateTime;
76    use URI::Escape;
77  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
78  use Net::Twitter;  use DateTime::Format::ISO8601;
79    
80    my $use_twitter = 1;
81    eval { require Net::Twitter; };
82    $use_twitter = 0 if ($@);
83    
84  my $import_dircproxy;  my $import_dircproxy;
85  my $log_path;  my $log_path;
# Line 257  sub get_from_log { Line 262  sub get_from_log {
262    
263          $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});          $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});
264          $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} });          $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} });
265          $sql .= " where date(time) = ? " if ($args->{date});          if ($args->{date}) {
266                    $args->{date} = DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd;
267                    $sql .= " where date(time) = ? ";
268            }
269          $sql .= " order by log.time desc";          $sql .= " order by log.time desc";
270          $sql .= " limit " . $args->{limit} if ($args->{limit});          $sql .= " limit " . $args->{limit} if ($args->{limit});
271    
# Line 546  POE::Session->create( inline_states => Line 554  POE::Session->create( inline_states =>
554    
555                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);
556    
557                  if ( my $twitter = meta( $nick, $channel, 'twitter' ) ) {                  if ( $use_twitter ) {
558                          my ($login,$passwd) = split(/\s+/,$twitter,2);                          if ( my $twitter = meta( $nick, $NICK, 'twitter' ) ) {
559                          _log("sending twitter for $nick/$login on $channel ");                                  my ($login,$passwd) = split(/\s+/,$twitter,2);
560                          my $bot = Net::Twitter->new( username=>$login, password=>$passwd );                                  _log("sending twitter for $nick/$login on $channel ");
561                          $bot->update("<${channel}> $msg");                                  my $bot = Net::Twitter->new( username=>$login, password=>$passwd );
562                                    $bot->update("<${channel}> $msg");
563                            }
564                  }                  }
565    
566      },      },
# Line 597  POE::Session->create( inline_states => Line 607  POE::Session->create( inline_states =>
607    
608                          my $sth = $dbh->prepare(qq{                          my $sth = $dbh->prepare(qq{
609                                  select                                  select
610                                          nick,                                          trim(both '_' from nick) as nick,
611                                          count(*) as count,                                          count(*) as count,
612                                          sum(length(message)) as len                                          sum(length(message)) as len
613                                  from log                                  from log
614                                  group by nick                                  group by trim(both '_' from nick)
615                                  order by len desc,count desc                                  order by len desc,count desc
616                                  limit $nr                                  limit $nr
617                          });                          });
# Line 830  p { margin: 0; padding: 0.1em; } Line 840  p { margin: 0; padding: 0.1em; }
840  .nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; }  .nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; }
841  .message { color: #000000; font-size: 100%; }  .message { color: #000000; font-size: 100%; }
842  .search { float: right; }  .search { float: right; }
843    a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none }
844    a:hover.tag { border: 1px solid #eee }
845    hr { border: 1px dashed #ccc; height: 1px; clear: both; }
846    /*
847  .col-0 { background: #ffff66 }  .col-0 { background: #ffff66 }
848  .col-1 { background: #a0ffff }  .col-1 { background: #a0ffff }
849  .col-2 { background: #99ff99 }  .col-2 { background: #99ff99 }
850  .col-3 { background: #ff9999 }  .col-3 { background: #ff9999 }
851  .col-4 { background: #ff66ff }  .col-4 { background: #ff66ff }
852  a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none }  */
 a:hover.tag { border: 1px solid #eee }  
 hr { border: 1px dashed #ccc; height: 1px; clear: both; }  
853  _END_OF_STYLE_  _END_OF_STYLE_
854    
855  my $max_color = 4;  my $max_color = 4;
856    
857    my @cols = qw(
858            #ffcccc #ccffe6 #ccccff #e6ccff #ffccff #ffcce6 #ff9999 #ffcc99 #ffff99
859            #ccff99 #99ff99 #99ffcc #99ccff #9999ff #cc99ff #ff6666 #ffb366 #ffff66
860            #66ff66 #66ffb3 #66b3ff #6666ff #ff3333 #33ff33 #3399ff #3333ff #ff3399
861            #a0a0a0 #ff0000 #ffff00 #80ff00 #0000ff #8000ff #ff00ff #ff0080 #994d00
862            #999900 #009900 #cc0066 #c0c0c0 #ccff99 #99ff33 #808080 #660033 #ffffff
863    );
864    
865    $max_color = 0;
866    foreach my $c (@cols) {
867            $style .= ".col-${max_color} { background: $c }\n";
868            $max_color++;
869    }
870    warn "defined $max_color colors for users...\n";
871    
872  my %nick_enumerator;  my %nick_enumerator;
873    
874  sub root_handler {  sub root_handler {
# Line 919  sub root_handler { Line 946  sub root_handler {
946                                  filter => {                                  filter => {
947                                          message => sub {                                          message => sub {
948                                                  my $m = shift || return;                                                  my $m = shift || return;
949    
950                                                    # protect HTML from wiki modifications
951                                                    sub e {
952                                                            my $t = shift;
953                                                            return 'uri_unescape{' . uri_escape($t) . '}';
954                                                    }
955    
956                                                  $m =~ s/($escape_re)/$escape{$1}/gs;                                                  $m =~ s/($escape_re)/$escape{$1}/gs;
957                                                  $m =~ s#($RE{URI}{HTTP})#<a href="$1">$1</a>#gs;                                                  $m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs;
958                                                  $m =~ s#$tag_regex#<a href="?tag=$1" class="tag">$1</a>#g;                                                  $m =~ s#$tag_regex#e(qq{<a href="?tag=$1" class="tag">$1</a>})#egs;
959                                                    $m =~ s#\*(\w+)\*#<b>$1</b>#gs;
960                                                    $m =~ s#_(\w+)_#<u>$1</u>#gs;
961                                                    $m =~ s#\/(\w+)\/#<i>$1</i>#gs;
962    
963                                                    $m =~ s#uri_unescape{([^}]+)}#uri_unescape($1)#egs;
964                                                  return $m;                                                  return $m;
965                                          },                                          },
966                                          nick => sub {                                          nick => sub {

Legend:
Removed from v.53  
changed lines
  Added in v.63

  ViewVC Help
Powered by ViewVC 1.1.26