/[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 51 by dpavlin, Sun Mar 18 16:03:24 2007 UTC revision 61 by dpavlin, Sat Apr 21 12:10:23 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    
79    my $use_twitter = 1;
80    eval { require Net::Twitter; };
81    $use_twitter = 0 if ($@);
82    
83  my $import_dircproxy;  my $import_dircproxy;
84  my $log_path;  my $log_path;
85  GetOptions(  GetOptions(
# Line 545  POE::Session->create( inline_states => Line 550  POE::Session->create( inline_states =>
550    
551                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);
552    
553                  if ( my $twitter = ( $nick, $channel, 'twitter' ) ) {                  if ( $use_twitter ) {
554                          _log("FIXME: send twitter for $nick on $channel [$twitter]");                          if ( my $twitter = meta( $nick, $NICK, 'twitter' ) ) {
555                                    my ($login,$passwd) = split(/\s+/,$twitter,2);
556                                    _log("sending twitter for $nick/$login on $channel ");
557                                    my $bot = Net::Twitter->new( username=>$login, password=>$passwd );
558                                    $bot->update("<${channel}> $msg");
559                            }
560                  }                  }
561    
562      },      },
# Line 593  POE::Session->create( inline_states => Line 603  POE::Session->create( inline_states =>
603    
604                          my $sth = $dbh->prepare(qq{                          my $sth = $dbh->prepare(qq{
605                                  select                                  select
606                                          nick,                                          trim(both '_' from nick) as nick,
607                                          count(*) as count,                                          count(*) as count,
608                                          sum(length(message)) as len                                          sum(length(message)) as len
609                                  from log                                  from log
610                                  group by nick                                  group by trim(both '_' from nick)
611                                  order by len desc,count desc                                  order by len desc,count desc
612                                  limit $nr                                  limit $nr
613                          });                          });
# Line 673  POE::Session->create( inline_states => Line 683  POE::Session->create( inline_states =>
683                          if ( ! defined( $1 ) ) {                          if ( ! defined( $1 ) ) {
684                                  my $sth = $dbh->prepare(qq{ select name,value,changed from meta where nick = ? and channel = ? });                                  my $sth = $dbh->prepare(qq{ select name,value,changed from meta where nick = ? and channel = ? });
685                                  $sth->execute( $nick, $channel );                                  $sth->execute( $nick, $channel );
686                                  $res = "config for $nick ";                                  $res = "config for $nick on $channel";
687                                  while ( my ($n,$v) = $sth->fetchrow_array ) {                                  while ( my ($n,$v) = $sth->fetchrow_array ) {
688                                          $res .= "| $n = $v";                                          $res .= " | $n = $v";
689                                  }                                  }
690                          } elsif ( ! $2 ) {                          } elsif ( ! $2 ) {
691                                  my $val = meta( $nick, $channel, $1 );                                  my $val = meta( $nick, $channel, $1 );
# Line 826  p { margin: 0; padding: 0.1em; } Line 836  p { margin: 0; padding: 0.1em; }
836  .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 ; }
837  .message { color: #000000; font-size: 100%; }  .message { color: #000000; font-size: 100%; }
838  .search { float: right; }  .search { float: right; }
839    a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none }
840    a:hover.tag { border: 1px solid #eee }
841    hr { border: 1px dashed #ccc; height: 1px; clear: both; }
842    /*
843  .col-0 { background: #ffff66 }  .col-0 { background: #ffff66 }
844  .col-1 { background: #a0ffff }  .col-1 { background: #a0ffff }
845  .col-2 { background: #99ff99 }  .col-2 { background: #99ff99 }
846  .col-3 { background: #ff9999 }  .col-3 { background: #ff9999 }
847  .col-4 { background: #ff66ff }  .col-4 { background: #ff66ff }
848  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; }  
849  _END_OF_STYLE_  _END_OF_STYLE_
850    
851  my $max_color = 4;  my $max_color = 4;
852    
853    my @cols = qw(
854            #ffcccc #ccffe6 #ccccff #e6ccff #ffccff #ffcce6 #ff9999 #ffcc99 #ffff99
855            #ccff99 #99ff99 #99ffcc #99ccff #9999ff #cc99ff #ff6666 #ffb366 #ffff66
856            #66ff66 #66ffb3 #66b3ff #6666ff #ff3333 #33ff33 #3399ff #3333ff #ff3399
857            #a0a0a0 #ff0000 #ffff00 #80ff00 #0000ff #8000ff #ff00ff #ff0080 #994d00
858            #999900 #009900 #cc0066 #c0c0c0 #ccff99 #99ff33 #808080 #660033 #ffffff
859    );
860    
861    $max_color = 0;
862    foreach my $c (@cols) {
863            $style .= ".col-${max_color} { background: $c }\n";
864            $max_color++;
865    }
866    warn "defined $max_color colors for users...\n";
867    
868  my %nick_enumerator;  my %nick_enumerator;
869    
870  sub root_handler {  sub root_handler {
# Line 915  sub root_handler { Line 942  sub root_handler {
942                                  filter => {                                  filter => {
943                                          message => sub {                                          message => sub {
944                                                  my $m = shift || return;                                                  my $m = shift || return;
945    
946                                                    # protect HTML from wiki modifications
947                                                    sub e {
948                                                            my $t = shift;
949                                                            return 'uri_unescape{' . uri_escape($t) . '}';
950                                                    }
951    
952                                                  $m =~ s/($escape_re)/$escape{$1}/gs;                                                  $m =~ s/($escape_re)/$escape{$1}/gs;
953                                                  $m =~ s#($RE{URI}{HTTP})#<a href="$1">$1</a>#gs;                                                  $m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs;
954                                                  $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;
955                                                    $m =~ s#\*(\w+)\*#<b>$1</b>#gs;
956                                                    $m =~ s#_(\w+)_#<u>$1</u>#gs;
957                                                    $m =~ s#\/(\w+)\/#<i>$1</i>#gs;
958    
959                                                    $m =~ s#uri_unescape{([^}]+)}#uri_unescape($1)#egs;
960                                                  return $m;                                                  return $m;
961                                          },                                          },
962                                          nick => sub {                                          nick => sub {

Legend:
Removed from v.51  
changed lines
  Added in v.61

  ViewVC Help
Powered by ViewVC 1.1.26