]> git.donarmstrong.com Git - infobot.git/blobdiff - blootbot/src/UserExtra.pl
sort chaninfo by people
[infobot.git] / blootbot / src / UserExtra.pl
index acf40dd61b8e4a224a8d36e9a5ec9c68db0112ed..33f93bf23de115d40a190ad69cd7dabd95799977 100644 (file)
@@ -6,7 +6,7 @@
 use strict;
 use vars qw($message $arg $qWord $verb $lobotomized $who $result $chan
        $conn $msgType $query $talkchannel $ident $memusage);
-use vars qw(%channels %chanstats %cmdstats %count %ircstats %param
+use vars qw(%channels %chanstats %cmdstats %count %forked %ircstats %param
        %cache %mask %userstats);
 
 ### hooks get added in CommandHooks.pl.
@@ -24,10 +24,11 @@ sub chaninfo {
        my $reply       = "I'm on \002$i\002 ".&fixPlural("channel",$i);
        my $tucount     = 0;    # total user count.
        my $uucount     = 0;    # unique user count.
+       my %chans;
        my @array;
 
        ### line 1.
-       foreach (sort keys %channels) {
+       foreach (keys %channels) {
            if ( /^\s*$/ or / / ) {
                &status("chanstats: fe channels: chan == NULL.");
                #&ircCheck();
@@ -35,8 +36,12 @@ sub chaninfo {
            }
            next if (/^_default$/);
 
-           my $str = sprintf("%s/%d", $_, scalar(keys %{ $channels{$_}{''} }));
-           push(@array, $str);
+           $chans{$_} = scalar(keys %{ $channels{$_}{''} });
+           #my $str = sprintf("%s/%d", $_, scalar(keys %{ $channels{$_}{''} }));
+           #push(@array, $str);
+       }
+       foreach $chan (sort {$chans{$b} <=> $chans{$a}} keys %chans) {
+           push(@array, "$chan/" . $chans{$chan});
        }
        &performStrictReply($reply.": ".join(', ', @array));
 
@@ -184,7 +189,7 @@ sub factinfo {
 sub factstats {
     my $type = shift(@_);
 
-    &Forker("factoids", sub {
+    &Forker("Factoids", sub {
        &performStrictReply( &CmdFactStats($type) );
     } );
 }
@@ -192,7 +197,7 @@ sub factstats {
 sub karma {
     my $target = lc( shift || $who );
     my $karma  = &sqlSelect("stats", "counter",
-       { nick => $target, type => "karma" }) || 0;
+       { nick => $target, type => "karma", channel => $chan }) || 0;
 
     if ($karma != 0) {
        &performStrictReply("$target has karma of $karma");
@@ -442,26 +447,13 @@ sub userCommands {
     }
 
     # crypt.
-    if ($message =~ /^crypt(\s+(.*))?$/i) {
-       my @args        = split /\s+/, $2;
-
-       if (!scalar @args or scalar @args > 2) {
-           &help("crypt");
-           return;
-       }
-
-       if (scalar @args == 2) {
-# disable cause $1$ will use md5
-#          if (length $args[0] != 2) {
-#              &msg($who, "invalid format...");
-#              return;
-#          }
-
-           &performStrictReply( crypt($args[1], $args[0]) );
+    if ($message =~ /^crypt\s+(\S*)?\s*(.*)?$/i) {
+&status("crypt: $1:$2:$3");
+       if ("$2" ne '') {
+           &performStrictReply(crypt($2, $1));
        } else {
-           &performStrictReply( &mkcrypt($args[0]) );
+           &performStrictReply(&mkcrypt($1));
        }
-
        return;
     }
 
@@ -711,23 +703,6 @@ sub userCommands {
        );
 
        return;
-
-       my %hash = &sqlSelectColHash("stats", "nick,counter",
-               { type => "cmdstats" }, 1);
-# ORDER won't be retained in a hash
-#                      " ORDER BY counter DESC", 1);
-
-if (0) {
-       foreach (keys %hash) {
-           my $i = $_;
-           foreach (keys %{ $hash{$i} }) {
-               &DEBUG("cmdstats: $hash{$i}{$_} = $_");
-           }
-       }
-       &DEBUG("end of cmdstats.");
-}
-
-       return;
     }
 
     # wantNick. xk++