]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
standard TODO: and FIXME:
[infobot.git] / src / CommandStubs.pl
index b1640ae66a01cccafa6fa0d79368b3b1ba8afcb6..a2f00ef6ba689718618a85cb7d7b931241c43fbf 100644 (file)
@@ -3,7 +3,8 @@
 # WARN: this file does not reload on HUP.
 #
 
-# use strict;  # TODO
+# TODO:
+# use strict;
 
 use vars qw($who $msgType $conn $chan $message $ident $talkchannel
        $bot_version $babel_lang_regex $bot_data_dir);
@@ -18,7 +19,7 @@ $w3search_regex   = "google";
 
 ### COMMAND HOOK IMPLEMENTATION.
 # addCmdHook("SECTION", 'TEXT_HOOK',
-#      (CODEREF        => 'Blah', 
+#      (CODEREF        => 'Blah',
 #      Forker          => 1,
 #      CheckModule     => 1,                   # ???
 #      Module          => 'blah.pl'            # preload module.
@@ -44,7 +45,8 @@ sub addCmdHook {
 # RUN IF ADDRESSED.
 sub parseCmdHook {
     my ($hashname, $line) = @_;
-    $line =~ /^(\S+)( (.*))?$/;
+    $line =~ s/^\s+|\s+$//g;   # again.
+    $line =~ /^(\S+)(\s+(.*))?$/;
     my $cmd    = $1;   # command name is whitespaceless.
     my $flatarg        = $3;
     my @args   = split(/\s+/, $flatarg || '');
@@ -73,7 +75,7 @@ sub parseCmdHook {
            next;
        }
 
-       &status("hooks($hashname): $cmd matched '$ident'");
+       &status("hooks($hashname): $cmd matched '$ident' '$flatarg'");
        my %hash = %{ ${"hooks_$hashname"}{$ident} };
 
        if (!scalar keys %hash) {
@@ -189,7 +191,7 @@ sub parseCmdHook {
        'Forker' => 1, 'Identifier' => 'kernel',
        'Cmdstats' => 'Kernel', 'NoArgs' => 1) );
 &addCmdHook("extra", 'listauth', ('CODEREF' => 'CmdListAuth',
-       'Identifier' => 'search', Module => 'factoids', 
+       'Identifier' => 'search', Module => 'factoids',
        'Help' => 'listauth') );
 &addCmdHook("extra", 'quote', ('CODEREF' => 'Quote::Quote',
        'Forker' => 1, 'Identifier' => 'quote',
@@ -247,6 +249,9 @@ sub parseCmdHook {
        '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) );
 
 ###
 ### END OF ADDING HOOKS.
@@ -278,7 +283,7 @@ sub Modules {
        return;
     }
 
-    my $debiancmd       = 'conflicts?|depends?|desc|file|info|provides?';
+    my $debiancmd       = 'conflicts?|depends?|desc|file|(?:d)?info|provides?';
     $debiancmd         .= '|recommends?|suggests?|maint|maintainer';
 
     if ($message =~ /^($debiancmd)(\s+(.*))?$/i) {
@@ -295,7 +300,7 @@ sub Modules {
     }
 
     # google searching. Simon++
-    if ($message =~ /^(?:search\s+)?($w3search_regex)\s+for\s+['"]?(.*?)["']?\s*\?*$/i) {
+    if ($message =~ /^(?:search\s+)?($w3search_regex)\s+(?:for\s+)?['"]?(.*?)["']?\s*\?*$/i) {
        return unless (&hasParam("wwwsearch"));
 
        &Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
@@ -846,7 +851,7 @@ sub do_text_counters {
     if (!defined $arg or $arg =~ /^\s*$/) {
        # this is way fucking ugly.
 
-       # TODO convert $where to hash
+       # TODO: convert $where to hash
        my %hash = &sqlSelectColHash("stats", "nick,counter",
                        { },
                        $where." ORDER BY counter DESC LIMIT 3", 1
@@ -874,7 +879,7 @@ sub do_text_counters {
            &pSReply("zero counter for \037$type\037.");
        }
     } else {
-       # TODO convert $where to hash and use a sqlSelect
+       # TODO: convert $where to hash and use a sqlSelect
        my $x = (&sqlRawReturn("SELECT SUM(counter) FROM stats".
                        " WHERE $where AND nick=".&sqlQuote($arg) ))[0];
 
@@ -884,7 +889,7 @@ sub do_text_counters {
        }
 
        # defined.
-       # TODO convert $where to hash
+       # TODO: convert $where to hash
        my @array = &sqlSelect("stats", "nick", undef,
                        $where." ORDER BY counter", 1
        );
@@ -958,7 +963,7 @@ sub textstats_main {
        return;
     }
 
-    # TODO add nick to where_href
+    # TODO: add nick to where_href
     my %hash = &sqlSelectColHash("stats", "type,counter",
                $where_href, " AND nick=".&sqlQuote($arg)
     );
@@ -971,7 +976,7 @@ sub textstats_main {
     foreach (keys %hash) {
        &DEBUG("_stats: hash{$_} => $hash{$_}");
        # ranking.
-       # TODO convert $where to hash
+       # TODO: convert $where to hash
        my @array = &sqlSelect("stats", "nick", undef,
                $where." ORDER BY counter", 1);
        $good = 0;