]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
news: added news->factoid redirection
[infobot.git] / src / UserExtra.pl
index e0c234a4cadc3580cb1e05503e77bc18af88b8ef..1a62202f5afccd530d38c3a853bab2a42d26356a 100644 (file)
@@ -30,8 +30,11 @@ use vars qw(%channels %chanstats %cmdstats);
        Help => 'nslookup', Identifier => 'allowDNS',
        Forker => "NULL", ) );
 &addCmdHook("main", 'tell|explain', ('CODEREF' => 'tell', 
-       Help => 'tell', Identifier => 'allowTelling', ) );
-
+       Help => 'tell', Identifier => 'allowTelling',
+       Cmdstats => 'Tell') );
+&addCmdHook("main", 'news', ('CODEREF' => 'News::Parse', 
+       Module => 'news', ) );
+#      Module => 'news', Identifier => 'news') );
 
 &status("CMD: loaded ".scalar(keys %hooks_main)." MAIN command hooks.");
 
@@ -75,6 +78,10 @@ sub chaninfo {
                push(@nicks, $_);
            }
        }
+       &DEBUG("nicks => '".scalar(@nicks)."'...");
+       if (scalar @nicks != $uucount) {
+           &DEBUG("nicks != uucount...");
+       }
 
        my $chans = scalar(keys %channels);
        &pSReply(
@@ -616,17 +623,31 @@ sub userCommands {
     }
 
     # ircstats.
-    if ($message =~ /^ircstats$/i) {
+    if ($message =~ /^ircstats?$/i) {
+       $ircstats{'TotalTime'}  ||= 0;
+       $ircstats{'OffTime'}    ||= 0;
+
        my $count       = $ircstats{'ConnectCount'};
        my $format_time = &Time2String(time() - $ircstats{'ConnectTime'});
-       my $total_time  = time() - $ircstats{'ConnectTime'} + $ircstats{'TotalTime'};
+       my $total_time  = time() - $ircstats{'ConnectTime'} +
+                               $ircstats{'TotalTime'};
        my $reply;
 
-       &DEBUG("ircstats: total_time => $total_time.");
-       &DEBUG("ircstats: offtime => $ircstats{'OffTime'}");
+       my $connectivity = 100 * ($total_time - $ircstats{'OffTime'}) /
+                               $total_time;
+       my $p = sprintf("%.02f", $connectivity);
+       $p =~ s/(\.\d*)0+$/$1/;
+       if ($p =~ s/\.0$//) {
+           &DEBUG("p sar not working properly :(");
+       } else {
+           $p =~ s/\.$//
+       }
+
+       &DEBUG("connectivity => $p %");
 
-       foreach (keys %ircstats) {
-           &DEBUG("ircstats: $_ => '$ircstats{$_}'.");
+       if ($total_time != (time() - $ircstats{'ConnectTime'}) ) {
+           my $tt_format = &Time2String($total_time);
+           &DEBUG("tt_format => $tt_format");
        }
 
        ### RECONNECT COUNT.