/[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 37 by dpavlin, Sun Jun 25 17:40:59 2006 UTC revision 40 by dpavlin, Tue Oct 24 12:50:41 2006 UTC
# Line 363  C<me> if not specified will be C<0> (not Line 363  C<me> if not specified will be C<0> (not
363  sub save_message {  sub save_message {
364          my $a = {@_};          my $a = {@_};
365          $a->{me} ||= 0;          $a->{me} ||= 0;
366            $a->{time} ||= strftime($TIMESTAMP,localtime());
367    
368          print          print
369                  $a->{time} ? $a->{time} . " " : strftime($TIMESTAMP,localtime()),                  $a->{time}, " ",
370                  $a->{channel}, " ",                  $a->{channel}, " ",
371                  $a->{me} ? "***" . $a->{nick} : "<" . $a->{nick} . ">",                  $a->{me} ? "***" . $a->{nick} : "<" . $a->{nick} . ">",
372                  " " . $a->{msg} . "\n";                  " " . $a->{msg} . "\n";
# Line 475  POE::Session->create( inline_states => Line 476  POE::Session->create( inline_states =>
476                          my $nr = $1 || 10;                          my $nr = $1 || 10;
477    
478                          my $sth = $dbh->prepare(qq{                          my $sth = $dbh->prepare(qq{
479                                  select nick,count(*) from log group by nick order by count desc limit $nr                                  select
480                                            nick,
481                                            count(*) as count,
482                                            sum(length(message)) as len
483                                    from log
484                                    group by nick
485                                    order by len desc,count desc
486                                    limit $nr
487                          });                          });
488                          $sth->execute();                          $sth->execute();
489                          $res = "Top $nr users: ";                          $res = "Top $nr users: ";
490                          my @users;                          my @users;
491                          while (my $row = $sth->fetchrow_hashref) {                          while (my $row = $sth->fetchrow_hashref) {
492                                  push @users,$row->{nick} . ': ' . $row->{count};                                  push @users,$row->{nick} . ': ' . $row->{count} . '/' . $row->{len} . '=' . sprintf("%.2f", $row->{len}/$row->{count});
493                          }                          }
494                          $res .= join(" | ", @users);                          $res .= join(" | ", @users);
495                  } elsif ($msg =~ m/^last.*?\s*(\d*)/i) {                  } elsif ($msg =~ m/^last.*?\s*(\d*)/i) {
496    
497                          foreach my $res (get_from_log( limit => $1 )) {                          foreach my $res (get_from_log( limit => ($1 || 100) )) {
498                                  print "last: $res\n";                                  print "last: $res\n";
499                                  from_to($res, $ENCODING, 'UTF-8');                                  from_to($res, $ENCODING, 'UTF-8');
500                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );                                  $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );

Legend:
Removed from v.37  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26