]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
- nice patch from Phil Edwards <pme@devphil.com>. Thanks!
[infobot.git] / src / CommandStubs.pl
index 7e5ccb6e1fa73ff43a6b143d121599bc09ad259a..cc0a3fb926a759a0eaaeceff275cf1f303beeb62 100644 (file)
@@ -14,6 +14,7 @@ use vars qw(%channels %cache %mask %userstats %myModules %cmdstats
 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";
+$w3search_regex   = "google";
 
 ### COMMAND HOOK IMPLEMENTATION.
 # addCmdHook("SECTION", 'TEXT_HOOK',
@@ -222,9 +223,6 @@ sub parseCmdHook {
 &addCmdHook("extra", 'uptime', ('CODEREF' => 'uptime', 'Identifier' => 'uptime',
        'Cmdstats' => 'Uptime') );
 &addCmdHook("extra", 'nullski', ('CODEREF' => 'nullski', ) );
-&addCmdHook("extra", '(fm|freshmeat)', ('CODEREF' => 'Freshmeat::Freshmeat',
-       'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat',
-       'Forker' => 1, 'Help' => 'freshmeat') );
 &addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) );
 &addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather',
        'Identifier' => 'weather', 'Help' => 'weather',
@@ -247,7 +245,7 @@ sub parseCmdHook {
 &addCmdHook("extra", '(ex)?change', ('CODEREF' => 'Exchange::query',
        'Identifier' => 'exchange', 'Cmdstats' => 'exchange',
        'Forker' => 1) );
-&addCmdHook("extra", 'botmail', ('CODEREF' => 'botmail::parse',
+&addCmdHook("extra", '(botmail|message)', ('CODEREF' => 'botmail::parse',
        'Identifier' => 'botmail', 'Cmdstats' => 'botmail') );
 
 ###
@@ -297,7 +295,7 @@ sub Modules {
     }
 
     # google searching. Simon++
-    if ($message =~ /^(?:search\s+)?(\S+)\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); } );
@@ -340,6 +338,7 @@ sub Modules {
            if (!defined $arg or $arg =~ /^\s*$/) {
                # this is way fucking ugly.
 
+               # TODO convert $where to hash
                my %hash = &sqlSelectColHash("stats", "nick,counter",
                        { },
                        $where." ORDER BY counter DESC LIMIT 3", 1
@@ -368,6 +367,7 @@ sub Modules {
                    &pSReply("zero counter for \037$type\037.");
                }
            } else {
+               # TODO convert $where to hash and use a sqlSelect
                my $x = (&sqlRawReturn("SELECT SUM(counter) FROM stats".
                        " WHERE $where AND nick=".&sqlQuote($arg) ))[0];
 
@@ -377,6 +377,7 @@ sub Modules {
                }
 
                # defined.
+               # TODO convert $where to hash
                my @array = &sqlSelect("stats", "nick", undef,
                        $where." ORDER BY counter", 1
                );
@@ -431,8 +432,8 @@ sub Modules {
            $args       =~ s/^["']|["']$//g;
        }
 
-       if (length $args == 1) {
-           &msg($who,"search string is too short.");
+       if (length $args < 2 && &IsFlag("o") ne "o") {
+           &msg($who, "search string is too short.");
            return;
        }
 
@@ -573,19 +574,6 @@ sub Modules {
     return "CONTINUE";
 }
 
-# Freshmeat. xk++
-sub freshmeat {
-    my ($query) = @_;
-
-    if (!defined $query) {
-       &help("freshmeat");
-       &msg($who, "I have \002".&countKeys("freshmeat")."\002 entries.");
-       return;
-    }
-
-    &Freshmeat::Freshmeat($query);
-}
-
 # Uptime. xk++
 sub uptime {
     my $count = 1;
@@ -961,6 +949,7 @@ sub textstats_main {
            &pSReply("zero counter for \037$type\037.");
        }
     } else {
+       # TODO add nick to where_href
        my %hash = &sqlSelectColHash("stats", "type,counter",
                $where_href, " AND nick=".&sqlQuote($arg)
        );
@@ -973,6 +962,7 @@ sub textstats_main {
        foreach (keys %hash) {
            &DEBUG("_stats: hash{$_} => $hash{$_}");
            # ranking.
+           # TODO convert $where to hash
            my @array = &sqlSelect("stats", "nick", undef,
                $where." ORDER BY counter", 1);
            $good = 0;