]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
- moved scripts/setup_sql.pl to src/db_mysql as &createTables()
[infobot.git] / src / UserExtra.pl
index 8f6aff3fb6712a1acf178303e47c5aea4b935166..2fd29f94b8f3664965929a1e86c266efb3e285eb 100644 (file)
@@ -33,7 +33,7 @@ use vars qw(%channels %chanstats %cmdstats);
        Help => 'tell', Identifier => 'allowTelling',
        Cmdstats => 'Tell') );
 &addCmdHook("main", 'news', ('CODEREF' => 'News::Parse', 
-       Module => 'news', ) );
+       Module => 'news', 'Cmdstats' => 'News' ) );
 &addCmdHook("main", 'countrystats', ('CODEREF' => 'countryStats', 
 #      Forker => "NULL",
  ) );
@@ -152,12 +152,17 @@ sub chaninfo {
     my %new;
     foreach (keys %userstats) {
        next unless (exists $userstats{$_}{'Count'});
+       if ($userstats{$_}{'Count'} =~ /^\D+$/) {
+           &WARN("userstats{$_}{Count} is non-digit.");
+           next;
+       }
+
        $new{$_} = $userstats{$_}{'Count'};
     }
 
-    my($count) = (sort { $b <=> $a } keys %new)[0];
+    my($count) = (sort { $a <=> $b } keys %new)[0];
     if ($count) {
-       $reply .= ".  \002$new{$count}\002 has said the most with a total of \002$count\002 messages";
+       $reply .= ".  \002$count\002 has said the most with a total of \002$new{$count}\002 messages";
     }
     &pSReply("$reply.");
 }
@@ -352,7 +357,7 @@ sub tell {
        $message        = $tell_obj;
        $done++ unless (&Modules());
 
-       &DEBUG("setting old values of who and msgType.");
+       &VERB("teel: setting old values of who and msgType.",2);
        $who            = $oldwho;
        $msgType        = $oldmtype;
 
@@ -678,21 +683,26 @@ sub userCommands {
 
        # utime(13) + stime(14).
        my $cpu_usage   = sprintf("%.01f", ($data[13]+$data[14]) / 100 );
+       # cutime(15) + cstime (16).
+       my $cpu_usage2  = sprintf("%.01f", ($data[15]+$data[16]) / 100 );
        my $time        = time() - $^T;
        my $raw_perc    = $cpu_usage*100/$time;
+       my $raw_perc2   = $cpu_usage2*100/$time;
        my $perc;
+       my $perc2;
 
        if ($raw_perc > 1) {
            $perc       = sprintf("%.01f", $raw_perc);
+           $perc2      = sprintf("%.01f", $raw_perc2);
        } elsif ($raw_perc > 0.1) {
            $perc       = sprintf("%.02f", $raw_perc);
+           $perc2      = sprintf("%.02f", $raw_perc2);
        } else {                        # <=0.1
            $perc       = sprintf("%.03f", $raw_perc);
+           $perc2      = sprintf("%.03f", $raw_perc2);
        }
 
-       &pSReply("Total CPU usage: $cpu_usage s ... Percentage CPU used: $perc %");
-       &DEBUG("15 => $data[15] (cutime)");
-       &DEBUG("16 => $data[16] (cstime)");
+       &pSReply("Total CPU usage: $cpu_usage s ... Percentage CPU used: $perc % (+childs: $perc2 %)");
 
        return;
     }
@@ -750,6 +760,10 @@ sub userCommands {
        my $startString = scalar(localtime $^T);
        my $upString    = &Time2String(time() - $^T);
        my $count       = &countKeys("factoids");
+       $count{'Commands'}      = 0;
+       foreach (keys %cmdstats) {
+           $count{'Commands'} += $cmdstats{$_};
+       }
 
        &pSReply(
        "Since $startString, there have been".
@@ -761,6 +775,8 @@ sub userCommands {
                &fixPlural("dunno",$count{'Dunno'}).
          " and \002$count{'Moron'}\002 ".
                &fixPlural("moron",$count{'Moron'}).
+         " and \002$count{'Commands'}\002 ".
+               &fixPlural("command",$count{'Commands'}).
          ".  I have been awake for $upString this session, and ".
          "currently reference \002$count\002 factoids.  ".
          "I'm using about \002$memusage\002 ".