]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
* New user flag "+s", to bypass +silent on channels
[infobot.git] / src / CommandStubs.pl
index b230798d595c8b9439e361d1712a4f334b65802f..ed89824cd814e11fa5f4861d93fd36f2395b053c 100644 (file)
@@ -3,21 +3,18 @@
 # WARN: this file does not reload on HUP.
 #
 
-# TODO:
-# use strict;
+#use strict; # TODO: sub { \&{ $hash{'CODEREF'} }($flatarg) };
 
 use vars qw($who $msgType $conn $chan $message $ident $talkchannel
        $bot_version $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);
-
-$w3search_regex   = "google";
+       %cmdhooks %lang %ver);
+# TODO: FIX THE FOLLOWING:
+use vars qw($total $x $type $i $good %wingateToDo);
 
 ### COMMAND HOOK IMPLEMENTATION.
-# addCmdHook("SECTION", 'TEXT_HOOK',
+# addCmdHook('TEXT_HOOK',
 #      (CODEREF        => 'Blah',
 #      Forker          => 1,
 #      Module          => 'blah.pl'            # preload module.
@@ -28,21 +25,21 @@ $w3search_regex   = "google";
 ###
 
 sub addCmdHook {
-    my ($hashname, $ident, %hash) = @_;
+    my ($ident, %hash) = @_;
 
-    if (exists ${"hooks_$hashname"}{$ident}) {
-###    &WARN("aCH: cmd hooks \%$hashname{$ident} already exists.");
+    if (exists $cmdhooks{$ident}) {
+       &WARN("aCH: \$cmdhooks{$ident} already exists.");
        return;
     }
 
     &VERB("aCH: added $ident",2);      # use $hash{'Identifier'}?
     ### hrm... prevent warnings?
-    ${"hooks_$hashname"}{$ident} = \%hash;
+    $cmdhooks{$ident} = \%hash;
 }
 
 # RUN IF ADDRESSED.
 sub parseCmdHook {
-    my ($hashname, $line) = @_;
+    my ($line) = @_;
     $line =~ s/^\s+|\s+$//g;   # again.
     $line =~ /^(\S+)(\s+(.*))?$/;
     my $cmd    = $1;   # command name is whitespaceless.
@@ -52,17 +49,17 @@ sub parseCmdHook {
 
     &shmFlush();
 
-    if (!defined %{"hooks_$hashname"}) {
-       &WARN("cmd hooks \%$hashname does not exist.");
+    if (!defined %cmdhooks) {
+       &WARN('%cmdhooks does not exist.');
        return 0;
     }
 
     if (!defined $cmd) {
-       &WARN("cstubs: cmd == NULL.");
+       &WARN('cstubs: cmd == NULL.');
        return 0;
     }
 
-    foreach (keys %{"hooks_$hashname"}) {
+    foreach (keys %cmdhooks) {
        # rename to something else! like $id or $label?
        my $ident = $_;
 
@@ -73,11 +70,11 @@ sub parseCmdHook {
            next;
        }
 
-       &status("hooks($hashname): $cmd matched '$ident' '$flatarg'");
-       my %hash = %{ ${"hooks_$hashname"}{$ident} };
+       &status("cmdhooks: $cmd matched '$ident' '$flatarg'");
+       my %hash = %{ $cmdhooks{$ident} };
 
        if (!scalar keys %hash) {
-           &WARN("CmdHook: hash is NULL?");
+           &WARN('CmdHook: hash is NULL?');
            return 1;
        }
 
@@ -104,7 +101,7 @@ sub parseCmdHook {
 
        ### IDENTIFIER.
        if (exists $hash{'Identifier'}) {
-           return 1 unless (&hasParam($hash{'Identifier'}));
+           return 1 unless (&IsChanConfOrWarn($hash{'Identifier'}));
        }
 
        ### USER FLAGS.
@@ -113,9 +110,7 @@ sub parseCmdHook {
        }
 
        ### FORKER,IDENTIFIER,CODEREF.
-       if (exists $hash{'Forker'}) {
-           $hash{'Identifier'} .= "-" if ($hash{'Forker'} eq "NULL");
-
+       if (($$ == $bot_pid) && exists $hash{'Forker'}) {
            if (exists $hash{'ArrayArgs'}) {
                &Forker($hash{'Identifier'}, sub { \&{ $hash{'CODEREF'} }(@args) } );
            } else {
@@ -124,7 +119,7 @@ sub parseCmdHook {
 
        } else {
            if (exists $hash{'Module'}) {
-               &loadMyModule($myModules{ $hash{'Module'} });
+               &loadMyModule($hash{'Module'});
            }
 
            # check if CODEREF exists.
@@ -149,7 +144,7 @@ sub parseCmdHook {
            $cmdstats{ $hash{'Cmdstats'} }++;
        }
 
-       &VERB("hooks: End of command.",2);
+       &VERB('hooks: End of command.',2);
 
        $done = 1;
     }
@@ -158,124 +153,9 @@ sub parseCmdHook {
     return 0;
 }
 
-###
-### START ADDING HOOKS.
-###
-&addCmdHook("extra", 'd?bugs', ('CODEREF' => 'DBugs::Parse',
-       'Forker' => 1, 'Identifier' => 'DebianExtra',
-       'Cmdstats' => 'Debian Bugs') );
-&addCmdHook("extra", 'dauthor', ('CODEREF' => 'Debian::searchAuthor',
-       'Forker' => 1, 'Identifier' => 'Debian',
-       'Cmdstats' => 'Debian Author Search', 'Help' => "dauthor" ) );
-&addCmdHook("extra", '(d|search)desc', ('CODEREF' => 'Debian::searchDescFE',
-       'Forker' => 1, 'Identifier' => 'Debian',
-       'Cmdstats' => 'Debian Desc Search', 'Help' => "ddesc" ) );
-&addCmdHook("extra", 'dnew', ('CODEREF' => 'DebianNew',
-       'Identifier' => 'Debian' ) );
-&addCmdHook("extra", 'dincoming', ('CODEREF' => 'Debian::generateIncoming',
-       'Forker' => 1, 'Identifier' => 'Debian' ) );
-&addCmdHook("extra", 'dstats', ('CODEREF' => 'Debian::infoStats',
-       'Forker' => 1, 'Identifier' => 'Debian',
-       'Cmdstats' => 'Debian Statistics' ) );
-&addCmdHook("extra", 'd?contents', ('CODEREF' => 'Debian::searchContents',
-       'Forker' => 1, 'Identifier' => 'Debian',
-       'Cmdstats' => 'Debian Contents Search', 'Help' => "contents" ) );
-&addCmdHook("extra", 'd?find', ('CODEREF' => 'Debian::DebianFind',
-       'Forker' => 1, 'Identifier' => 'Debian',
-       'Cmdstats' => 'Debian Search', 'Help' => "find" ) );
-&addCmdHook("extra", 'insult', ('CODEREF' => 'Insult::Insult',
-       'Forker' => 1, 'Identifier' => 'insult', 'Help' => "insult" ) );
-&addCmdHook("extra", 'kernel', ('CODEREF' => 'Kernel::Kernel',
-       'Forker' => 1, 'Identifier' => 'Kernel',
-       'Cmdstats' => 'Kernel', 'NoArgs' => 1) );
-&addCmdHook("extra", 'listauth', ('CODEREF' => 'CmdListAuth',
-       'Identifier' => 'Search', Module => 'Factoids',
-       'Help' => 'listauth') );
-&addCmdHook("extra", 'quote', ('CODEREF' => 'Quote::Quote',
-       'Forker' => 1, 'Identifier' => 'Quote',
-       'Help' => 'quote', 'Cmdstats' => 'Quote') );
-&addCmdHook("extra", 'countdown', ('CODEREF' => 'countdown',
-       'Module' => 'countdown', 'Identifier' => 'countdown',
-       'Cmdstats' => 'countdown') );
-&addCmdHook("extra", 'lart', ('CODEREF' => 'lart',
-       'Identifier' => 'lart', 'Help' => 'lart') );
-&addCmdHook("extra", 'convert', ('CODEREF' => 'convert',
-       'Forker' => 1, 'Identifier' => 'units',
-       'Help' => 'convert') );
-&addCmdHook("extra", '(cookie|random)', ('CODEREF' => 'cookie',
-       'Forker' => 1, 'Identifier' => 'Factoids') );
-&addCmdHook("extra", 'u(ser)?info', ('CODEREF' => 'userinfo',
-       'Identifier' => 'userinfo', 'Help' => 'userinfo',
-       'Module' => 'userinfo') );
-&addCmdHook("extra", 'RootWarn', ('CODEREF' => 'CmdrootWarn',
-       'Identifier' => 'RootWarn', 'Module' => 'RootWarn') );
-&addCmdHook("extra", 'seen', ('CODEREF' => 'seen', 'Identifier' =>
-       'seen') );
-&addCmdHook("extra", 'Dict', ('CODEREF' => 'Dict::Dict',
-       'Identifier' => 'Dict', 'Help' => 'dict',
-       'Forker' => 1, 'Cmdstats' => 'Dict') );
-&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', ) );
-&addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) );
-&addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather',
-       'Identifier' => 'weather', 'Help' => 'weather',
-       'Cmdstats' => 'weather', 'Forker' => 1) );
-&addCmdHook("extra", 'metar', ('CODEREF' => 'Weather::Metar',
-       'Identifier' => 'weather', 'Help' => 'weather',
-       'Cmdstats' => 'weather', 'Forker' => 1) );
-&addCmdHook("extra", 'bzflist', ('CODEREF' => 'BZFlag::list',
-       'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag',
-       'Forker' => 1) );
-&addCmdHook("extra", 'bzflist17', ('CODEREF' => 'BZFlag::list17',
-       'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag',
-       'Forker' => 1) );
-&addCmdHook("extra", 'bzfquery', ('CODEREF' => 'BZFlag::query',
-       'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag',
-       'Forker' => 1) );
-&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|message)', ('CODEREF' => 'botmail::parse',
-       'Identifier' => 'botmail', 'Cmdstats' => 'botmail') );
-&addCmdHook("extra", 'HTTPDtype', ('CODEREF' => 'HTTPDtype::HTTPDtype',
-       'Identifier' => 'HTTPDtype', 'Cmdstats' => 'HTTPDtype',
-       'Forker' => 1) );
-&addCmdHook("extra", 'Rss', ('CODEREF' => 'Rss::Rss',
-       'Identifier' => 'Rss', 'Cmdstats' => 'Rss',
-       'Forker' => 1, 'Help' => 'rss') );
-&addCmdHook("extra", 'wiki(pedia)?', ('CODEREF' => 'wikipedia::wikipedia',
-       'Identifier' => 'wikipedia', 'Cmdstats' => 'wikipedia',
-       'Forker' => 1, 'Help' => 'wikipedia') );
-&addCmdHook("extra", 'page', ('CODEREF' => 'pager::page',
-       'Identifier' => 'pager', 'Cmdstats' => 'pager',
-       'Forker' => 1, 'Help' => 'page') );
-&addCmdHook("extra", 'babel(fish)?|x|xlate|translate', ('CODEREF' => 'babelfish::babelfish',
-       'Identifier' => 'babelfish', 'Cmdstats' => 'babelfish',
-       'Forker' => 1, 'Help' => 'babelfish') );
-###
-### END OF ADDING HOOKS.
-###
-&status("CMD: loaded ".scalar(keys %hooks_extra)." EXTRA command hooks.");
-
 sub Modules {
     if (!defined $message) {
-       &WARN("Modules: message is undefined. should never happen.");
+       &WARN('Modules: message is undefined. should never happen.');
        return;
     }
 
@@ -283,11 +163,11 @@ sub Modules {
     $debiancmd         .= '|recommends?|suggests?|maint|maintainer';
 
     if ($message =~ /^($debiancmd)(\s+(.*))?$/i) {
-       return unless (&hasParam("debian"));
+       return unless (&IsChanConfOrWarn('Debian'));
        my $package = lc $3;
 
        if (defined $package) {
-           &Forker("debian", sub { &Debian::infoPackages($1, $package); } );
+           &Forker('Debian', sub { &Debian::infoPackages($1, $package); } );
        } else {
            &help($1);
        }
@@ -296,12 +176,13 @@ sub Modules {
     }
 
     # google searching. Simon++
+    my $w3search_regex   = 'google';
     if ($message =~ /^(?:search\s+)?($w3search_regex)\s+(?:for\s+)?['"]?(.*?)["']?\s*\?*$/i) {
-       return unless (&hasParam("wwwsearch"));
+       return unless (&IsChanConfOrWarn('W3Search'));
 
-       &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
+       &Forker('W3Search', sub { &W3Search::W3Search($1,$2); } );
 
-       $cmdstats{'WWWSearch'}++;
+       $cmdstats{'W3Search'}++;
        return;
     }
 
@@ -314,10 +195,10 @@ sub Modules {
 
     # list{keys|values}. xk++. Idea taken from #linuxwarez@EFNET
     if ($message =~ /^list(\S+)(\s+(.*))?$/i) {
-       return unless (&hasParam("search"));
+       return unless (&IsChanConfOrWarn('Search'));
 
        my $thiscmd     = lc $1;
-       my $args        = $3 || "";
+       my $args        = $3 || '';
 
        $thiscmd        =~ s/^vals$/values/;
        return if ($thiscmd ne 'keys' && $thiscmd ne 'values');
@@ -345,75 +226,13 @@ sub Modules {
        return;
     }
 
-    # Nickometer. Adam Spiers++
-    if ($message =~ /^(?:lame|nick)ometer(?: for)? (\S+)/i) {
-       return unless (&hasParam("nickometer"));
-
-       my $term = (lc $1 eq 'me') ? $who : $1;
-
-       &loadMyModule($myModules{'nickometer'});
-
-       if ($term =~ /^$mask{chan}$/) {
-           &status("Doing nickometer for chan $term.");
-
-           if (!&validChan($term)) {
-               &msg($who, "error: channel is invalid.");
-               return;
-           }
-
-           # step 1.
-           my %nickometer;
-           foreach (keys %{ $channels{lc $term}{''} }) {
-               my $str   = $_;
-               if (!defined $str) {
-                   &WARN("nickometer: nick in chan $term undefined?");
-                   next;
-               }
-
-               my $value = &nickometer($str);
-               $nickometer{$value}{$str} = 1;
-           }
-
-           # step 2.
-           ### TODO: compact with map?
-           my @list;
-           foreach (sort {$b <=> $a} keys %nickometer) {
-               my $str = join(", ", sort keys %{ $nickometer{$_} });
-               push(@list, "$str ($_%)");
-           }
-
-           &pSReply( &formListReply(0, "Nickometer list for $term ", @list) );
-           &DEBUG("test.");
-
-           return;
-       }
-
-       my $percentage = &nickometer($term);
-
-       if ($percentage =~ /NaN/) {
-           $percentage = "off the scale";
-       } else {
-           $percentage = sprintf("%0.4f", $percentage);
-           $percentage =~ s/(\.\d+)0+$/$1/;
-           $percentage .= '%';
-       }
-
-       if ($msgType eq 'public') {
-           &say("'$term' is $percentage lame, $who");
-       } else {
-           &msg($who, "the 'lame nick-o-meter' reading for $term is $percentage, $who");
-       }
-
-       return;
-    }
-
     # Topic management. xk++
     # may want to add a userflags for topic. -xk
     if ($message =~ /^topic(\s+(.*))?$/i) {
-       return unless (&hasParam("topic"));
+       return unless (&IsChanConfOrWarn('Topic'));
 
        my $chan        = $talkchannel;
-       my @args        = split / /, $2 || "";
+       my @args        = split / /, $2 || '';
 
        if (!scalar @args) {
            &msg($who,"Try 'help topic'");
@@ -425,14 +244,14 @@ sub Modules {
 
        # topic over public:
        if ($msgType eq 'public' && $thiscmd =~ /^#/) {
-           &msg($who, "error: channel argument is not required.");
+           &msg($who, 'error: channel argument is not required.');
            &msg($who, "\002Usage\002: topic <CMD>");
            return;
        }
 
        # topic over private:
        if ($msgType eq 'private' && $chan !~ /^#/) {
-           &msg($who, "error: channel argument is required.");
+           &msg($who, 'error: channel argument is required.');
            &msg($who, "\002Usage\002: topic #channel <CMD>");
            return;
        }
@@ -449,7 +268,7 @@ sub Modules {
        }
 
        # now lets do it.
-       &loadMyModule($myModules{'topic'});
+       &loadMyModule('Topic');
        &Topic($chan, $thiscmd, join(' ', @args));
        $cmdstats{'Topic'}++;
        return;
@@ -457,23 +276,23 @@ sub Modules {
 
     # wingate.
     if ($message =~ /^wingate$/i) {
-       return unless (&hasParam("wingate"));
+       return unless (&IsChanConfOrWarn('Wingate'));
 
        my $reply = "Wingate statistics: scanned \002"
-                       .scalar(keys %wingate)."\002 hosts";
+                       .scalar(keys %wingateToDo)."\002 hosts";
        my $queue = scalar(keys %wingateToDo);
        if ($queue) {
            $reply .= ".  I have \002$queue\002 hosts in the queue";
-           $reply .= ".  Started the scan ".&Time2String(time() - $wingaterun)." ago";
+           $reply .= '.  Started the scan '.&Time2String(time() - $wingaterun).' ago';
        }
 
-       &pSReply("$reply.");
+       &performStrictReply("$reply.");
 
        return;
     }
 
     # do nothing and let the other routines have a go
-    return "CONTINUE";
+    return 'CONTINUE';
 }
 
 # Uptime. xk++
@@ -498,11 +317,11 @@ sub seen {
     $person =~ s/\?*$//;
 
     if (!defined $person or $person =~ /^$/) {
-       &help("seen");
+       &help('seen');
 
-       my $i = &countKeys("seen");
-       &msg($who,"there ". &fixPlural("is",$i) ." \002$i\002 ".
-               "seen ". &fixPlural("entry",$i) ." that I know of.");
+       my $i = &countKeys('seen');
+       &msg($who,'there '. &fixPlural('is',$i) ." \002$i\002 ".
+               'seen '. &fixPlural('entry',$i) .' that I know of.');
 
        return;
     }
@@ -512,11 +331,11 @@ sub seen {
     &seenFlush();      # very evil hack. oh well, better safe than sorry.
 
     # TODO: convert to &sqlSelectRowHash();
-    my $select = "nick,time,channel,host,message";
-    if ($person eq "random") {
-       @seen = &randKey("seen", $select);
+    my $select = 'nick,time,channel,host,message,messagecount';
+    if ($person eq 'random') {
+       @seen = &randKey('seen', $select);
     } else {
-       @seen = &sqlSelect("seen", $select, { nick => $person } );
+       @seen = &sqlSelect('seen', $select, { nick => $person } );
     }
 
     if (scalar @seen < 2) {
@@ -537,18 +356,19 @@ sub seen {
        $reply = "$seen[0] is currently on";
 
        foreach (@chans) {
-           $reply .= " ".$_;
+           $reply .= ' '.$_;
            next unless (exists $userstats{lc $seen[0]}{'Join'});
-           $reply .= " (".&Time2String(time() - $userstats{lc $seen[0]}{'Join'}).")";
+           $reply .= ' ('.&Time2String(time() - $userstats{lc $seen[0]}{'Join'}).')';
        }
 
-       if (&IsChanConf("seenStats") > 0) {
+       if (&IsChanConf('seenStats') > 0) {
            my $i;
-           $i = $userstats{lc $seen[0]}{'Count'};
-           $reply .= ".  Has said a total of \002$i\002 messages" if (defined $i);
+           $i = $seen[6] || $userstats{lc $seen[0]}{'Count'};
+           $reply .= ". Has said a total of \002$i\002 messages" if (defined $i);
            $i = $userstats{lc $seen[0]}{'Time'};
-           $reply .= ".  Is idling for ".&Time2String(time() - $i) if (defined $i);
+           $reply .= '. Is idling for '.&Time2String(time() - $i) if (defined $i);
        }
+       $reply .= ", last said\002:\002 '$seen[4]'.";
     } else {
        my $howlong = &Time2String(time() - $seen[1]);
        $reply = "$seen[0] <$seen[3]> was last seen on IRC ".
@@ -556,7 +376,7 @@ sub seen {
                 "saying\002:\002 '$seen[4]'.";
     }
 
-    &pSReply($reply);
+    &performStrictReply($reply);
     return;
 }
 
@@ -567,7 +387,7 @@ sub userinfo {
     if ($arg =~ /^set(\s+(.*))?$/i) {
        $arg = $2;
        if (!defined $arg) {
-           &help("userinfo set");
+           &help('userinfo set');
            return;
        }
 
@@ -575,11 +395,11 @@ sub userinfo {
     } elsif ($arg =~ /^unset(\s+(.*))?$/i) {
        $arg = $2;
        if (!defined $arg) {
-           &help("userinfo unset");
+           &help('userinfo unset');
            return;
        }
 
-       &UserInfoSet($arg, "");
+       &UserInfoSet($arg, '');
     } else {
        &UserInfoGet($arg);
     }
@@ -597,11 +417,11 @@ sub cookie {
     ### WILL CHEW TONS OF MEM.
     ### TODO: convert this to a Forker function!
     if ($arg) {
-       my @list = &searchTable("factoids", "factoid_key", "factoid_value", $arg);
+       my @list = &searchTable('factoids', 'factoid_key', 'factoid_value', $arg);
        $key    = &getRandom(@list);
-       $value  = &getFactInfo($key, "factoid_value");
+       $value  = &getFactInfo($key, 'factoid_value');
     } else {
-       ($key,$value) = &randKey("factoids","factoid_key,factoid_value");
+       ($key,$value) = &randKey('factoids','factoid_key,factoid_value');
     }
 
     for ($cookiemsg) {
@@ -628,8 +448,8 @@ sub convert {
     ($from,$to) = ($2,$1) if ($arg =~ /^(.*?) from (.*)$/i);
 
     if (!$to or !$from) {
-       &msg($who, "Invalid format!");
-       &help("convert");
+       &msg($who, 'Invalid format!');
+       &help('convert');
        return;
     }
 
@@ -640,9 +460,10 @@ sub convert {
 
 sub lart {
     my ($target) = &fixString($_[0]);
-    my $extra  = 0;
+    my $extra  = 0;
     my $chan   = $talkchannel;
     my ($for);
+    my $mynick = $conn->nick();
 
     if ($msgType eq 'private') {
        if ($target =~ /^($mask{chan})\s+(.*)$/) {
@@ -650,8 +471,8 @@ sub lart {
            $target     = $2;
            $extra      = 1;
        } else {
-           &msg($who, "error: invalid format or missing arguments.");
-           &help("lart");
+           &msg($who, 'error: invalid format or missing arguments.');
+           &help('lart');
            return;
        }
     }
@@ -660,9 +481,9 @@ sub lart {
        $for    = $2;
     }
 
-    my $line = &getRandomLineFromFile($bot_data_dir. "/blootbot.lart");
+    my $line = &getRandomLineFromFile($bot_data_dir. '/infobot.lart');
     if (defined $line) {
-       if ($target =~ /^(me|you|itself|\Q$ident\E)$/i) {
+       if ($target =~ /^(me|you|itself|\Q$mynick\E)$/i) {
            $line =~ s/WHO/$who/g;
        } else {
            $line =~ s/WHO/$target/g;
@@ -672,12 +493,12 @@ sub lart {
 
        &action($chan, $line);
     } else {
-       &status("lart: error reading file?");
+       &status('lart: error reading file?');
     }
 }
 
 sub DebianNew {
-    my $idx   = "debian/Packages-sid.idx";
+    my $idx   = 'debian/Packages-sid.idx';
     my $error = 0;
     my %pkg;
     my @new;
@@ -686,7 +507,7 @@ sub DebianNew {
     $error++ unless ( -e "$idx-old");
 
     if ($error) {
-       $error = "no sid/sid-old index file found.";
+       $error = 'no sid/sid-old index file found.';
        &ERROR("Debian: $error");
        &msg($who, $error);
        return;
@@ -713,14 +534,14 @@ sub DebianNew {
     }
     close IDX1;
 
-    &::pSReply( &::formListReply(0, "New debian packages:", @new) );
+    &::performStrictReply( &::formListReply(0, 'New debian packages:', @new) );
 }
 
 sub do_verstats {
     my ($chan) = @_;
 
     if (!defined $chan) {
-       &help("verstats");
+       &help('verstats');
        return;
     }
 
@@ -730,12 +551,12 @@ sub do_verstats {
     }
 
     if (scalar @vernick > scalar(keys %{ $channels{lc $chan}{''} })/4) {
-       &msg($who, "verstats already in progress for someone else.");
+       &msg($who, 'verstats already in progress for someone else.');
        return;
     }
 
     &msg($who, "Sending CTCP VERSION to $chan; results in 60s.");
-    $conn->ctcp("VERSION", $chan);
+    $conn->ctcp('VERSION', $chan);
     $cache{verstats}{chan}     = $chan;
     $cache{verstats}{who}      = $who;
     $cache{verstats}{msgType}  = $msgType;
@@ -769,7 +590,7 @@ sub do_verstats {
        my $unknown     = $total - $vtotal;
        my $perc        = sprintf("%.1f", $unknown * 100 / $total);
        $perc           =~ s/.0$//;
-       $sorted{$perc}{"unknown/cloak"} = "$unknown ($perc%)" if ($unknown);
+       $sorted{$perc}{'unknown/cloak'} = "$unknown ($perc%)" if ($unknown);
 
        foreach (keys %ver) {
            my $count   = scalar keys %{ $ver{$_} };
@@ -790,7 +611,7 @@ sub do_verstats {
 
        # hack. this is one major downside to scheduling.
        $chan = $c;
-       &pSReply( &formListReply(0, "IRC Client versions for $c ", @list) );
+       &performStrictReply( &formListReply(0, "IRC Client versions for $c ", @list) );
 
        # clean up not-needed data structures.
        undef %ver;
@@ -805,7 +626,7 @@ sub verstats_flush {
        last unless (scalar @vernicktodo);
 
        my $n = shift(@vernicktodo);
-       $conn->ctcp("VERSION", $n);
+       $conn->ctcp('VERSION', $n);
     }
 
     return unless (scalar @vernicktodo);
@@ -818,7 +639,7 @@ sub do_text_counters {
     $itc =~ s/([^\w\s])/\\$1/g;
     my $z = join '|', split ' ', $itc;
 
-    if ($msgType eq "privmsg" and $message =~ / ($mask{chan})$/) {
+    if ($msgType eq 'privmsg' and $message =~ / ($mask{chan})$/) {
        &DEBUG("ircTC: privmsg detected; chan = $1");
        $chan = $1;
     }
@@ -838,25 +659,25 @@ sub do_text_counters {
 
     # even more uglier with channel/time arguments.
     my $c      = $chan;
-#   my $c      = $chan || "PRIVATE";
-    my $where  = "type=".&sqlQuote($type);
+#   my $c      = $chan || 'PRIVATE';
+    my $where  = 'type='.&sqlQuote($type);
     if (defined $c) {
        &DEBUG("c => $c");
-       $where  .= " AND channel=".&sqlQuote($c) if (defined $c);
+       $where  .= ' AND channel='.&sqlQuote($c) if (defined $c);
     } else {
-       &DEBUG("not using chan arg");
+       &DEBUG('not using chan arg');
     }
 
-    my $sum = (&sqlRawReturn("SELECT SUM(counter) FROM stats"
-                       ." WHERE ".$where ))[0];
+    my $sum = (&sqlRawReturn('SELECT SUM(counter) FROM stats'
+                       .' WHERE '.$where ))[0];
 
     if (!defined $arg or $arg =~ /^\s*$/) {
-       # this is way fucking ugly.
+       # this is way ugly.
 
        # TODO: convert $where to hash
-       my %hash = &sqlSelectColHash("stats", "nick,counter",
+       my %hash = &sqlSelectColHash('stats', 'nick,counter',
                        { },
-                       $where." ORDER BY counter DESC LIMIT 3", 1
+                       $where.' ORDER BY counter DESC LIMIT 3', 1
        );
        my $i;
        my @top;
@@ -870,30 +691,30 @@ sub do_text_counters {
                push(@top, "\002$_\002 -- $i ($p%)");
            }
        }
-       my $topstr = "";
+       my $topstr = '';
        if (scalar @top) {
-           $topstr = ".  Top ".scalar(@top).": ".join(', ', @top);
+           $topstr = '.  Top '.scalar(@top).': '.join(', ', @top);
        }
 
        if (defined $sum) {
-           &pSReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
+           &performStrictReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
        } else {
-           &pSReply("zero counter for \037$type\037.");
+           &performStrictReply("zero counter for \037$type\037.");
        }
     } else {
        # TODO: convert $where to hash and use a sqlSelect
-       my $x = (&sqlRawReturn("SELECT SUM(counter) FROM stats".
+       my $x = (&sqlRawReturn('SELECT SUM(counter) FROM stats'.
                        " WHERE $where AND nick=".&sqlQuote($arg) ))[0];
 
        if (!defined $x) {      # !defined.
-           &pSReply("$arg has not said $type yet.");
+           &performStrictReply("$arg has not said $type yet.");
            return 1;
        }
 
        # defined.
        # TODO: convert $where to hash
-       my @array = &sqlSelect("stats", "nick", undef,
-                       $where." ORDER BY counter", 1
+       my @array = &sqlSelect('stats', 'nick', undef,
+                       $where.' ORDER BY counter', 1
        );
        my $good = 0;
        my $i = 0;
@@ -905,14 +726,14 @@ sub do_text_counters {
        $i++;
 
        my $total = scalar(@array);
-       my $xtra = "";
+       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 $pct1 = sprintf("%.01f", 100*$x/$sum);
-       &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
+       &performStrictReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
     }
 
     return 1;
@@ -923,20 +744,20 @@ sub textstats_main {
 
     # even more uglier with channel/time arguments.
     my $c      = $chan;
-#    my $c     = $chan || "PRIVATE";
-    &DEBUG("not using chan arg") if (!defined $c);
+#    my $c     = $chan || 'PRIVATE';
+    &DEBUG('not using chan arg') if (!defined $c);
 
     # example of converting from RawReturn to sqlSelect.
-    my $where_href = (defined $c) ? { channel => $c } : "";
-    my $sum = &sqlSelect("stats", "SUM(counter)", $where_href);
+    my $where_href = (defined $c) ? { channel => $c } : '';
+    my $sum = &sqlSelect('stats', 'SUM(counter)', $where_href);
 
     if (!defined $arg or $arg =~ /^\s*$/) {
-       # this is way fucking ugly.
-       &DEBUG("_stats: !arg");
+       # this is way ugly.
+       &DEBUG('_stats: !arg');
 
-       my %hash = &sqlSelectColHash("stats", "nick,counter",
+       my %hash = &sqlSelectColHash('stats', 'nick,counter',
                $where_href,
-               " ORDER BY counter DESC LIMIT 3", 1
+               ' ORDER BY counter DESC LIMIT 3', 1
        );
        my $i;
        my @top;
@@ -951,25 +772,26 @@ sub textstats_main {
            }
        }
 
-       my $topstr = "";
+       my $topstr = '';
        if (scalar @top) {
-           $topstr = ".  Top ".scalar(@top).": ".join(', ', @top);
+           $topstr = '.  Top '.scalar(@top).': '.join(', ', @top);
        }
 
        if (defined $sum) {
-           &pSReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
+           &performStrictReply("total count of \037$type\037 on \002$c\002: $sum$topstr");
        } else {
-           &pSReply("zero counter for \037$type\037.");
+           &performStrictReply("zero counter for \037$type\037.");
        }
 
        return;
     }
 
     # TODO: add nick to where_href
-    my %hash = &sqlSelectColHash("stats", "type,counter",
-               $where_href, " AND nick=".&sqlQuote($arg)
+    my %hash = &sqlSelectColHash('stats', 'type,counter',
+               $where_href, ' AND nick='.&sqlQuote($arg)
     );
-    # this is totally fucked... needs to be fixed... and cleaned up.
+
+    # this is totally messed up... needs to be fixed... and cleaned up.
     my $total;
     my $good;
     my $ii;
@@ -979,8 +801,8 @@ sub textstats_main {
        &DEBUG("_stats: hash{$_} => $hash{$_}");
        # ranking.
        # TODO: convert $where to hash
-       my @array = &sqlSelect("stats", "nick", undef,
-               $where." ORDER BY counter", 1);
+       my $where = '';
+       my @array = &sqlSelect('stats', 'nick', undef, $where.' ORDER BY counter', 1);
        $good = 0;
        $ii = 0;
        for(my $i=0; $i<scalar @array; $i++) {
@@ -992,24 +814,24 @@ sub textstats_main {
 
        $total = scalar(@array);
        &DEBUG("   i => $i, good => $good, total => $total");
-       $x .= " ".$total."blah blah";
+       $x .= ' '.$total.'blah blah';
     }
 
 #    return;
 
     if (!defined $x) { # !defined.
-       &pSReply("$arg has not said $type yet.");
+       &performStrictReply("$arg has not said $type yet.");
        return;
     }
 
-    my $xtra = "";
+    my $xtra = '';
     if ($total and $good) {
        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);
-    &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
+    &performStrictReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
 }
 
 sub nullski {
@@ -1019,4 +841,76 @@ sub nullski {
     #foreach (`$arg`) { &msg($who,$_); }
 }
 
+%cmdhooks=();
+###
+### START ADDING HOOKS.
+###
+&addCmdHook('(babel(fish)?|x|xlate|translate)', ('CODEREF' => 'babelfish::babelfish', 'Identifier' => 'babelfish', 'Cmdstats' => 'babelfish', 'Forker' => 1, 'Help' => 'babelfish', 'Module' => 'babelfish') );
+&addCmdHook('(botmail|message)', ('CODEREF' => 'botmail::parse', 'Identifier' => 'botmail', 'Cmdstats' => 'botmail') );
+&addCmdHook('bzflist17', ('CODEREF' => 'BZFlag::list17', 'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag', 'Forker' => 1, 'Module' => 'BZFlag') );
+&addCmdHook('bzflist', ('CODEREF' => 'BZFlag::list', 'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag', 'Forker' => 1, 'Module' => 'BZFlag') );
+&addCmdHook('bzfquery', ('CODEREF' => 'BZFlag::query', 'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag', 'Forker' => 1, 'Module' => 'BZFlag') );
+&addCmdHook('chan(stats|info)', ('CODEREF' => 'chaninfo', ) );
+&addCmdHook('cmd(stats|info)', ('CODEREF' => 'cmdstats', ) );
+&addCmdHook('convert', ('CODEREF' => 'convert', 'Forker' => 1, 'Identifier' => 'Units', 'Help' => 'convert') );
+&addCmdHook('(cookie|random)', ('CODEREF' => 'cookie', 'Forker' => 1, 'Identifier' => 'Factoids') );
+&addCmdHook('countdown', ('CODEREF' => 'countdown', 'Module' => 'countdown', 'Identifier' => 'countdown', 'Cmdstats' => 'countdown') );
+&addCmdHook('countrystats', ('CODEREF' => 'countryStats') );
+&addCmdHook('dauthor', ('CODEREF' => 'Debian::searchAuthor', 'Forker' => 1, 'Identifier' => 'Debian', 'Cmdstats' => 'Debian Author Search', 'Help' => 'dauthor' ) );
+&addCmdHook('d?bugs', ('CODEREF' => 'DebianExtra::Parse', 'Forker' => 1, 'Identifier' => 'DebianExtra', 'Cmdstats' => 'Debian Bugs') );
+&addCmdHook('d?contents', ('CODEREF' => 'Debian::searchContents', 'Forker' => 1, 'Identifier' => 'Debian', 'Cmdstats' => 'Debian Contents Search', 'Help' => 'contents' ) );
+&addCmdHook('d?find', ('CODEREF' => 'Debian::DebianFind', 'Forker' => 1, 'Identifier' => 'Debian', 'Cmdstats' => 'Debian Search', 'Help' => 'find' ) );
+&addCmdHook('dice', ('CODEREF' => 'dice::dice', 'Identifier' => 'dice', 'Cmdstats' => 'dice', 'Forker' => 1, 'Module' => 'dice') );
+&addCmdHook('Dict', ('CODEREF' => 'Dict::Dict', 'Identifier' => 'Dict', 'Help' => 'dict', 'Forker' => 1, 'Cmdstats' => 'Dict') );
+&addCmdHook('dincoming', ('CODEREF' => 'Debian::generateIncoming', 'Forker' => 1, 'Identifier' => 'Debian' ) );
+&addCmdHook('dnew', ('CODEREF' => 'DebianNew', 'Identifier' => 'Debian' ) );
+&addCmdHook('dns|d?nslookup', ('CODEREF' => 'dns::query', 'Identifier' => 'dns', 'Cmdstats' => 'dns', 'Forker' => 1, 'Help' => 'dns') );
+&addCmdHook('(d|search)desc', ('CODEREF' => 'Debian::searchDescFE', 'Forker' => 1, 'Identifier' => 'Debian', 'Cmdstats' => 'Debian Desc Search', 'Help' => 'ddesc' ) );
+&addCmdHook('dstats', ('CODEREF' => 'Debian::infoStats', 'Forker' => 1, 'Identifier' => 'Debian', 'Cmdstats' => 'Debian Statistics' ) );
+&addCmdHook('(ex)?change', ('CODEREF' => 'Exchange::query', 'Identifier' => 'Exchange', 'Cmdstats' => 'Exchange', 'Forker' => 1) );
+&addCmdHook('factinfo', ('CODEREF' => 'factinfo', 'Cmdstats' => 'Factoid Info', Module => 'Factoids', ) );
+&addCmdHook('factstats?', ('CODEREF' => 'factstats', 'Cmdstats' => 'Factoid Stats', Help => 'factstats', Forker => 1, 'Identifier' => 'Factoids', ) );
+&addCmdHook('help', ('CODEREF' => 'help', 'Cmdstats' => 'Help', ) );
+&addCmdHook('HTTPDtype', ('CODEREF' => 'HTTPDtype::HTTPDtype', 'Identifier' => 'HTTPDtype', 'Cmdstats' => 'HTTPDtype', 'Forker' => 1) );
+&addCmdHook('[ia]?spell', ('CODEREF' => 'spell::query', 'Identifier' => 'spell', 'Cmdstats' => 'spell', 'Forker' => 1, 'Help' => 'spell') );
+&addCmdHook('insult', ('CODEREF' => 'Insult::Insult', 'Forker' => 1, 'Identifier' => 'insult', 'Help' => 'insult' ) );
+&addCmdHook('karma', ('CODEREF' => 'karma', ) );
+&addCmdHook('kernel', ('CODEREF' => 'Kernel::Kernel', 'Forker' => 1, 'Identifier' => 'Kernel', 'Cmdstats' => 'Kernel', 'NoArgs' => 1) );
+&addCmdHook('lart', ('CODEREF' => 'lart', 'Identifier' => 'lart', 'Help' => 'lart') );
+&addCmdHook('lc', ('CODEREF' => 'case::lower', 'Identifier' => 'case', 'Cmdstats' => 'case', 'Forker' => 1, 'Module' => 'case') );
+&addCmdHook('listauth', ('CODEREF' => 'CmdListAuth', 'Identifier' => 'Search', Module => 'Factoids', 'Help' => 'listauth') );
+&addCmdHook('md5(sum)?', ('CODEREF' => 'md5::md5', 'Identifier' => 'md5', 'Cmdstats' => 'md5', 'Forker' => 1, 'Module' => 'md5') );
+&addCmdHook('metar', ('CODEREF' => 'Weather::Metar', 'Identifier' => 'Weather', 'Help' => 'weather', 'Cmdstats' => 'Weather', 'Forker' => 1) );
+&addCmdHook('News', ('CODEREF' => 'News::Parse', Module => 'News', 'Cmdstats' => 'News', 'Identifier' => 'News' ) );
+&addCmdHook('(?:nick|lame)ometer(?: for)?', ('CODEREF' => 'nickometer::query', 'Identifier' => 'nickometer', 'Cmdstats' => 'nickometer', 'Forker' => 1) );
+&addCmdHook('nullski', ('CODEREF' => 'nullski', ) );
+&addCmdHook('page', ('CODEREF' => 'pager::page', 'Identifier' => 'pager', 'Cmdstats' => 'pager', 'Forker' => 1, 'Help' => 'page') );
+&addCmdHook('piglatin', ('CODEREF' => 'piglatin::piglatin', 'Identifier' => 'piglatin', 'Cmdstats' => 'piglatin', 'Forker' => 1) );
+&addCmdHook('Plug', ('CODEREF' => 'Plug::Plug', 'Identifier' => 'Plug', 'Forker' => 1, 'Cmdstats' => 'Plug') );
+&addCmdHook('quote', ('CODEREF' => 'Quote::Quote', 'Forker' => 1, 'Identifier' => 'Quote', 'Help' => 'quote', 'Cmdstats' => 'Quote') );
+&addCmdHook('reverse', ('CODEREF' => 'reverse::reverse', 'Identifier' => 'reverse', 'Cmdstats' => 'reverse', 'Forker' => 1, 'Module' => 'reverse') );
+&addCmdHook('RootWarn', ('CODEREF' => 'CmdrootWarn', 'Identifier' => 'RootWarn', 'Module' => 'RootWarn') );
+&addCmdHook('OnJoin', ('CODEREF' => 'Cmdonjoin', 'Identifier' => 'OnJoin', 'Module' => 'OnJoin') );
+&addCmdHook('Rss', ('CODEREF' => 'Rss::Rss', 'Identifier' => 'Rss', 'Cmdstats' => 'Rss', 'Forker' => 1, 'Help' => 'rss') );
+&addCmdHook('sched(stats|info)', ('CODEREF' => 'scheduleList', ) );
+&addCmdHook('scramble', ('CODEREF' => 'scramble::scramble', 'Identifier' => 'scramble', 'Cmdstats' => 'scramble', 'Forker' => 1, 'Module' => 'scramble') );
+&addCmdHook('seen', ('CODEREF' => 'seen', 'Identifier' => 'seen') );
+&addCmdHook('slashdot', ('CODEREF' => 'Slashdot::Slashdot', 'Identifier' => 'slashdot', 'Forker' => 1, 'Cmdstats' => 'slashdot') );
+&addCmdHook('tell|explain', ('CODEREF' => 'tell', Help => 'tell', Identifier => 'allowTelling', Cmdstats => 'Tell') );
+&addCmdHook('uc', ('CODEREF' => 'case::upper', 'Identifier' => 'case', 'Cmdstats' => 'case', 'Forker' => 1, 'Module' => 'case') );
+&addCmdHook('Uptime', ('CODEREF' => 'uptime', 'Identifier' => 'Uptime', 'Cmdstats' => 'Uptime') );
+&addCmdHook('u(ser)?info', ('CODEREF' => 'userinfo', 'Identifier' => 'UserInfo', 'Help' => 'userinfo', 'Module' => 'UserInfo') );
+&addCmdHook('verstats', ('CODEREF' => 'do_verstats' ) );
+&addCmdHook('Weather', ('CODEREF' => 'Weather::Weather', 'Identifier' => 'Weather', 'Help' => 'weather', 'Cmdstats' => 'Weather', 'Forker' => 1, 'Module' => 'Weather') );
+&addCmdHook('wiki(pedia)?', ('CODEREF' => 'wikipedia::wikipedia', 'Identifier' => 'wikipedia', 'Cmdstats' => 'wikipedia', 'Forker' => 1, 'Help' => 'wikipedia', 'Module' => 'wikipedia') );
+&addCmdHook('wtf', ('CODEREF' => 'wtf::query', 'Identifier' => 'wtf', 'Cmdstats' => 'wtf', 'Forker' => 1, 'Help' => 'wtf', 'Module' => 'wtf') );
+&addCmdHook('zfi', ('CODEREF' => 'zfi::query', 'Identifier' => 'zfi', 'Cmdstats' => 'zfi', 'Forker' => 1, 'Module' => 'zfi') );
+&addCmdHook('(zippy|yow)', ('CODEREF' => 'zippy::get', 'Identifier' => 'Zippy', 'Cmdstats' => 'Zippy', 'Forker' => 1, 'Module' => 'Zippy') );
+&addCmdHook('zsi', ('CODEREF' => 'zsi::query', 'Identifier' => 'zsi', 'Cmdstats' => 'zsi', 'Forker' => 1, 'Module' => 'zsi') );
+###
+### END OF ADDING HOOKS.
+###
+
+&status('loaded '.scalar(keys %cmdhooks).' command hooks.');
+
 1;