--- trunk/irc-logger.pl 2006/06/25 17:40:59 37 +++ trunk/irc-logger.pl 2006/10/24 12:50:41 40 @@ -363,9 +363,10 @@ sub save_message { my $a = {@_}; $a->{me} ||= 0; + $a->{time} ||= strftime($TIMESTAMP,localtime()); print - $a->{time} ? $a->{time} . " " : strftime($TIMESTAMP,localtime()), + $a->{time}, " ", $a->{channel}, " ", $a->{me} ? "***" . $a->{nick} : "<" . $a->{nick} . ">", " " . $a->{msg} . "\n"; @@ -475,18 +476,25 @@ my $nr = $1 || 10; my $sth = $dbh->prepare(qq{ - select nick,count(*) from log group by nick order by count desc limit $nr + select + nick, + count(*) as count, + sum(length(message)) as len + from log + group by nick + order by len desc,count desc + limit $nr }); $sth->execute(); $res = "Top $nr users: "; my @users; while (my $row = $sth->fetchrow_hashref) { - push @users,$row->{nick} . ': ' . $row->{count}; + push @users,$row->{nick} . ': ' . $row->{count} . '/' . $row->{len} . '=' . sprintf("%.2f", $row->{len}/$row->{count}); } $res .= join(" | ", @users); } elsif ($msg =~ m/^last.*?\s*(\d*)/i) { - foreach my $res (get_from_log( limit => $1 )) { + foreach my $res (get_from_log( limit => ($1 || 100) )) { print "last: $res\n"; from_to($res, $ENCODING, 'UTF-8'); $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );