]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
fix death
[infobot.git] / src / CommandStubs.pl
index 1a55669aef5b19ad323f1480aa82a45997506e3f..8d48eac309cceb6cde2635eebbcce5dc7c3f21bf 100644 (file)
@@ -3,9 +3,17 @@
 # WARN: this file does not reload on HUP.
 #
 
-if (&IsParam("useStrict")) { use strict; }
+# use strict;  # TODO
 
-$babel_lang_regex = "fr|sp|po|pt|it|ge|de|gr|en";
+use vars qw($who $msgType $conn $chan $message $ident $talkchannel
+       $bot_version $babel_lang_regex $bot_data_dir);
+use vars qw(@vernick @vernicktodo);
+use vars qw(%channels %cache %mask %userstats %myModules %cmdstats
+       %hooks_extra %lang %ver);
+# FIX THE FOLLOWING:
+use vars qw($total $x $type $i $good);
+
+$babel_lang_regex = "fr|sp|es|po|pt|it|ge|de|gr|en|zh|ja|jp|ko|kr|ru";
 
 ### COMMAND HOOK IMPLEMENTATION.
 # addCmdHook("SECTION", 'TEXT_HOOK',
@@ -120,7 +128,7 @@ sub parseCmdHook {
 
            # check if CODEREF exists.
            if (!defined &{ $hash{'CODEREF'} }) {
-               &WARN("coderef $hash{'CODEREF'} don't exist.");
+               &WARN("coderef $hash{'CODEREF'} does not exist.");
                if (defined $who) {
                    &msg($who, "coderef does not exist for $ident.");
                }
@@ -208,6 +216,9 @@ sub parseCmdHook {
 &addCmdHook("extra", 'slashdot', ('CODEREF' => 'Slashdot::Slashdot',
        'Identifier' => 'slashdot', 'Forker' => 1,
        'Cmdstats' => 'Slashdot') );
+&addCmdHook("extra", 'plug', ('CODEREF' => 'Plug::Plug',
+       'Identifier' => 'plug', 'Forker' => 1,
+       'Cmdstats' => 'Plug') );
 &addCmdHook("extra", 'uptime', ('CODEREF' => 'uptime', 'Identifier' => 'uptime',
        'Cmdstats' => 'Uptime') );
 &addCmdHook("extra", 'nullski', ('CODEREF' => 'nullski', ) );
@@ -215,6 +226,29 @@ sub parseCmdHook {
        'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat',
        'Forker' => 1, 'Help' => 'freshmeat') );
 &addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) );
+&addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather',
+       'Identifier' => 'weather', 'Help' => 'weather',
+       'Cmdstats' => 'weather', 'Forker' => 1) );
+&addCmdHook("extra", 'bzflist', ('CODEREF' => 'BZFlag::list',
+       'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag',
+       'Forker' => 1) );
+&addCmdHook("extra", 'bzfquery', ('CODEREF' => 'BZFlag::query',
+       'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag',
+       'Forker' => 1, 'Help' => 'bzflag') );
+&addCmdHook("extra", 'zfi', ('CODEREF' => 'zfi::query',
+       'Identifier' => 'zfi', 'Cmdstats' => 'zfi',
+       'Forker' => 1) );
+&addCmdHook("extra", '(zippy|yow)', ('CODEREF' => 'zippy::get',
+       'Identifier' => 'zippy', 'Cmdstats' => 'zippy',
+       'Forker' => 1) );
+&addCmdHook("extra", 'zsi', ('CODEREF' => 'zsi::query',
+       'Identifier' => 'zsi', 'Cmdstats' => 'zsi',
+       'Forker' => 1) );
+&addCmdHook("extra", '(ex)?change', ('CODEREF' => 'Exchange::query',
+       'Identifier' => 'exchange', 'Cmdstats' => 'exchange',
+       'Forker' => 1) );
+&addCmdHook("extra", 'botmail', ('CODEREF' => 'botmail::parse',
+       'Identifier' => 'botmail', 'Cmdstats' => 'botmail') );
 
 ###
 ### END OF ADDING HOOKS.
@@ -232,9 +266,9 @@ sub Modules {
                ^\s*
                (?:babel(?:fish)?|x|xlate|translate)
                \s+
-               (to|from)               # direction of translation (through)
+               ($babel_lang_regex)\w*  # from language?
                \s+
-               ($babel_lang_regex)\w*  # which language?
+               ($babel_lang_regex)\w*  # to language?
                \s*
                (.+)                    # The phrase to be translated
     }xoi) {
@@ -381,7 +415,6 @@ sub Modules {
        my $args        = $3 || "";
 
        $thiscmd        =~ s/^vals$/values/;
-#      $args           =~ s/\s+$//g;
        return if ($thiscmd ne "keys" && $thiscmd ne "values");
 
        # Usage:
@@ -456,7 +489,7 @@ sub Modules {
            $percentage = "off the scale";
        } else {
            $percentage = sprintf("%0.4f", $percentage);
-           $percentage =~ s/\.?0+$//;
+           $percentage =~ s/(\.\d+)0+$/$1/;
            $percentage .= '%';
        }
 
@@ -529,7 +562,7 @@ sub Modules {
            $reply .= ".  Started the scan ".&Time2String(time() - $wingaterun)." ago";
        }
 
-       &performStrictReply("$reply.");
+       &pSReply("$reply.");
 
        return;
     }
@@ -672,8 +705,8 @@ sub cookie {
     ### TODO: convert this to a Forker function!
     if ($arg) {
        my @list = &searchTable("factoids", "factoid_key", "factoid_value", $arg);
-       $key  = &getRandom(@list);
-       $val  = &getFactInfo("factoids", $key, "factoid_value");
+       $key    = &getRandom(@list);
+       $value  = &getFactInfo($key, "factoid_value");
     } else {
        ($key,$value) = &randKey("factoids","factoid_key,factoid_value");
     }
@@ -745,7 +778,7 @@ sub lart {
 }
 
 sub DebianNew {
-    my $idx   = "debian/Packages-woody.idx";
+    my $idx   = "debian/Packages-sid.idx";
     my $error = 0;
     my %pkg;
     my @new;
@@ -754,7 +787,7 @@ sub DebianNew {
     $error++ unless ( -e "$idx-old");
 
     if ($error) {
-       $error = "no woody/woody-old index file found.";
+       $error = "no sid/sid-old index file found.";
        &ERROR("Debian: $error");
        &msg($who, $error);
        return;
@@ -777,11 +810,11 @@ sub DebianNew {
        next if (/^\*/);
        next if (exists $pkg{$_});
 
-       push(@new);
+       push(@new, $_);
     }
     close IDX1;
 
-    &::performStrictReply( &::formListReply(0, "New debian packages:", @new) );
+    &::pSReply( &::formListReply(0, "New debian packages:", @new) );
 }
 
 sub do_verstats {
@@ -802,7 +835,7 @@ sub do_verstats {
        return;
     }
 
-    &msg($who, "Sending CTCP VERSION to #$chan...");
+    &msg($who, "Sending CTCP VERSION to $chan; results in 60s.");
     $conn->ctcp("VERSION", $chan);
     $cache{verstats}{chan}     = $chan;
     $cache{verstats}{who}      = $who;
@@ -856,6 +889,8 @@ sub do_verstats {
            }
        }
 
+       # hack. this is one major downside to scheduling.
+       $chan = $c;
        &pSReply( &formListReply(0, "IRC Client versions for $c ", @list) );
 
        # clean up not-needed data structures.
@@ -924,23 +959,29 @@ sub textstats_main {
     } else {
        my %hash = &dbGetCol("stats", "type,counter",
                "$where AND nick=".&dbQuote($arg) );
+       # this is totally fucked... needs to be fixed... and cleaned up.
+       my $total;
+       my $good;
+       my $ii;
+       my $x;
 
        foreach (keys %hash) {
            &DEBUG("_stats: hash{$_} => $hash{$_}");
            # ranking.
            my @array = &dbGet("stats", "nick",
                $where." ORDER BY counter", 1);
-           my $good = 0;
-           my $i = 0;
-           for($i=0; $i<scalar @array; $i++) {
+           $good = 0;
+           $ii = 0;
+           for(my $i=0; $i<scalar @array; $i++) {
                next unless ($array[0] =~ /^\Q$who\E$/);
                $good++;
                last;
            }
-           $i++;
+           $ii++;
 
-           my $total = scalar(@array);
+           $total = scalar(@array);
            &DEBUG("   i => $i, good => $good, total => $total");
+           $x .= " ".$total."blah blah";
        }
 
        return;
@@ -952,8 +993,8 @@ sub textstats_main {
 
        my $xtra = "";
        if ($total and $good) {
-           my $pct = sprintf("%.01f", 100*(1+$total-$i)/$total);
-           $xtra = ", ranked $i\002/\002$total (percentile: \002$pct\002 %)";
+           my $pct = sprintf("%.01f", 100*(1+$total-$ii)/$total);
+           $xtra = ", ranked $ii\002/\002$total (percentile: \002$pct\002 %)";
        }
 
        my $pct1 = sprintf("%.01f", 100*$x/$sum);