]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
re-order as ircCheck changes our nick
[infobot.git] / src / CommandStubs.pl
index e6098a7601eaac62c3a135d63d76ca83bfb0761f..eb8e7df4adcbe0395d27f16a947c53ae5817fc27 100644 (file)
@@ -104,7 +104,7 @@ sub parseCmdHook {
 
        ### IDENTIFIER.
        if (exists $hash{'Identifier'}) {
-           return 1 unless (&hasParam($hash{'Identifier'}));
+           return 1 unless (&IsChanConfOrWarn($hash{'Identifier'}));
        }
 
        ### USER FLAGS.
@@ -124,7 +124,7 @@ sub parseCmdHook {
 
        } else {
            if (exists $hash{'Module'}) {
-               &loadMyModule($myModules{ $hash{'Module'} });
+               &loadMyModule($hash{'Module'});
            }
 
            # check if CODEREF exists.
@@ -161,7 +161,7 @@ sub parseCmdHook {
 ###
 ### START ADDING HOOKS.
 ###
-&addCmdHook("extra", 'd?bugs', ('CODEREF' => 'DBugs::Parse',
+&addCmdHook("extra", 'd?bugs', ('CODEREF' => 'DebianExtra::Parse',
        'Forker' => 1, 'Identifier' => 'DebianExtra',
        'Cmdstats' => 'Debian Bugs') );
 &addCmdHook("extra", 'dauthor', ('CODEREF' => 'Debian::searchAuthor',
@@ -189,10 +189,10 @@ 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',
+       'Forker' => 1, 'Identifier' => 'Quote',
        'Help' => 'quote', 'Cmdstats' => 'Quote') );
 &addCmdHook("extra", 'countdown', ('CODEREF' => 'countdown',
        'Module' => 'countdown', 'Identifier' => 'countdown',
@@ -200,15 +200,15 @@ sub parseCmdHook {
 &addCmdHook("extra", 'lart', ('CODEREF' => 'lart',
        'Identifier' => 'lart', 'Help' => 'lart') );
 &addCmdHook("extra", 'convert', ('CODEREF' => 'convert',
-       'Forker' => 1, 'Identifier' => 'units',
+       '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') );
+       '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',
@@ -216,20 +216,20 @@ sub parseCmdHook {
        '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' => 'slashdot') );
+&addCmdHook("extra", 'Plug', ('CODEREF' => 'Plug::Plug',
+       'Identifier' => 'Plug', 'Forker' => 1,
        'Cmdstats' => 'Plug') );
-&addCmdHook("extra", 'uptime', ('CODEREF' => 'uptime', 'Identifier' => 'uptime',
+&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", '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) );
+       'Identifier' => 'Weather', 'Help' => 'weather',
+       'Cmdstats' => 'Weather', 'Forker' => 1) );
 &addCmdHook("extra", 'bzflist', ('CODEREF' => 'BZFlag::list',
        'Identifier' => 'BZFlag', 'Cmdstats' => 'BZFlag',
        'Forker' => 1) );
@@ -243,7 +243,7 @@ sub parseCmdHook {
        'Identifier' => 'zfi', 'Cmdstats' => 'zfi',
        'Forker' => 1) );
 &addCmdHook("extra", '(zippy|yow)', ('CODEREF' => 'zippy::get',
-       'Identifier' => 'zippy', 'Cmdstats' => 'zippy',
+       'Identifier' => 'Zippy', 'Cmdstats' => 'Zippy',
        'Forker' => 1) );
 &addCmdHook("extra", 'zsi', ('CODEREF' => 'zsi::query',
        'Identifier' => 'zsi', 'Cmdstats' => 'zsi',
@@ -256,8 +256,14 @@ sub parseCmdHook {
 &addCmdHook("extra", 'HTTPDtype', ('CODEREF' => 'HTTPDtype::HTTPDtype',
        'Identifier' => 'HTTPDtype', 'Cmdstats' => 'HTTPDtype',
        'Forker' => 1) );
-&addCmdHook("extra", 'rss', ('CODEREF' => 'Rss::Rss',
-       'Identifier' => 'rss', 'Cmdstats' => 'rss',
+&addCmdHook("extra", 'scramble', ('CODEREF' => 'scramble::scramble',
+       'Identifier' => 'scramble', 'Cmdstats' => 'scramble',
+       'Forker' => 1) );
+&addCmdHook("extra", 'md5(sum)?', ('CODEREF' => 'md5::md5',
+       'Identifier' => 'md5', 'Cmdstats' => 'md5',
+       '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',
@@ -265,9 +271,18 @@ sub parseCmdHook {
 &addCmdHook("extra", 'page', ('CODEREF' => 'pager::page',
        'Identifier' => 'pager', 'Cmdstats' => 'pager',
        'Forker' => 1, 'Help' => 'page') );
-&addCmdHook("extra", 'babel(fish)?|x|xlate|translate', ('CODEREF' => 'babelfish::babelfish',
+&addCmdHook("extra", '(babel(fish)?|x|xlate|translate)', ('CODEREF' => 'babelfish::babelfish',
        'Identifier' => 'babelfish', 'Cmdstats' => 'babelfish',
        'Forker' => 1, 'Help' => 'babelfish') );
+&addCmdHook("extra", 'wtf', ('CODEREF' => 'wtf::query',
+       'Identifier' => 'wtf', 'Cmdstats' => 'wtf',
+       'Forker' => 1, 'Help' => 'wtf') );
+&addCmdHook("extra", '[ia]?spell', ('CODEREF' => 'spell::query',
+       'Identifier' => 'spell', 'Cmdstats' => 'spell',
+       'Forker' => 1, 'Help' => 'spell') );
+&addCmdHook("extra", 'dns|d?nslookup|host', ('CODEREF' => 'dns::query',
+       'Identifier' => 'dns', 'Cmdstats' => 'dns',
+       'Forker' => 1, 'Help' => 'dns') );
 ###
 ### END OF ADDING HOOKS.
 ###
@@ -283,11 +298,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);
        }
@@ -297,49 +312,49 @@ sub Modules {
 
     # google searching. Simon++
     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;
     }
 
     # text counters. (eg: hehstats)
     my $itc;
-    $itc = &getChanConf("ircTextCounters");
-    $itc = &findChanConf("ircTextCounters") unless ($itc);
+    $itc = &getChanConf('ircTextCounters');
+    $itc = &findChanConf('ircTextCounters') unless ($itc);
     return if ($itc && &do_text_counters($itc) == 1);
     # end of text counters.
 
     # 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 || "";
 
        $thiscmd        =~ s/^vals$/values/;
-       return if ($thiscmd ne "keys" && $thiscmd ne "values");
+       return if ($thiscmd ne 'keys' && $thiscmd ne 'values');
 
        # Usage:
        if (!defined $args or $args =~ /^\s*$/) {
-           &help("list". $thiscmd);
+           &help('list'. $thiscmd);
            return;
        }
 
        # suggested by asuffield and \broken.
        if ($args =~ /^["']/ and $args =~ /["']$/) {
-           &DEBUG("list*: removed quotes.");
+           &DEBUG('list*: removed quotes.');
            $args       =~ s/^["']|["']$//g;
        }
 
-       if (length $args < 2 && &IsFlag("o") ne "o") {
-           &msg($who, "search string is too short.");
+       if (length $args < 2 && &IsFlag('o') ne 'o') {
+           &msg($who, 'search string is too short.');
            return;
        }
 
-       &Forker("search", sub { &Search::Search($thiscmd, $args); } );
+       &Forker('Search', sub { &Search::Search($thiscmd, $args); } );
 
        $cmdstats{'Factoid Search'}++;
        return;
@@ -347,11 +362,11 @@ sub Modules {
 
     # Nickometer. Adam Spiers++
     if ($message =~ /^(?:lame|nick)ometer(?: for)? (\S+)/i) {
-       return unless (&hasParam("nickometer"));
+       return unless (&IsChanConfOrWarn("nickometer"));
 
        my $term = (lc $1 eq 'me') ? $who : $1;
 
-       &loadMyModule($myModules{'nickometer'});
+       &loadMyModule('nickometer');
 
        if ($term =~ /^$mask{chan}$/) {
            &status("Doing nickometer for chan $term.");
@@ -382,7 +397,7 @@ sub Modules {
                push(@list, "$str ($_%)");
            }
 
-           &pSReply( &formListReply(0, "Nickometer list for $term ", @list) );
+           &performStrictReply( &formListReply(0, "Nickometer list for $term ", @list) );
            &DEBUG("test.");
 
            return;
@@ -410,7 +425,7 @@ sub Modules {
     # 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 || "";
@@ -449,7 +464,7 @@ sub Modules {
        }
 
        # now lets do it.
-       &loadMyModule($myModules{'topic'});
+       &loadMyModule('Topic');
        &Topic($chan, $thiscmd, join(' ', @args));
        $cmdstats{'Topic'}++;
        return;
@@ -457,7 +472,7 @@ 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";
@@ -467,7 +482,7 @@ sub Modules {
            $reply .= ".  Started the scan ".&Time2String(time() - $wingaterun)." ago";
        }
 
-       &pSReply("$reply.");
+       &performStrictReply("$reply.");
 
        return;
     }
@@ -556,7 +571,7 @@ sub seen {
                 "saying\002:\002 '$seen[4]'.";
     }
 
-    &pSReply($reply);
+    &performStrictReply($reply);
     return;
 }
 
@@ -567,7 +582,7 @@ sub userinfo {
     if ($arg =~ /^set(\s+(.*))?$/i) {
        $arg = $2;
        if (!defined $arg) {
-           &help("userinfo set");
+           &help('userinfo set');
            return;
        }
 
@@ -575,11 +590,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);
     }
@@ -640,7 +655,7 @@ sub convert {
 
 sub lart {
     my ($target) = &fixString($_[0]);
-    my $extra  = 0;
+    my $extra  = 0;
     my $chan   = $talkchannel;
     my ($for);
 
@@ -713,7 +728,7 @@ sub DebianNew {
     }
     close IDX1;
 
-    &::pSReply( &::formListReply(0, "New debian packages:", @new) );
+    &::performStrictReply( &::formListReply(0, "New debian packages:", @new) );
 }
 
 sub do_verstats {
@@ -790,7 +805,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;
@@ -876,9 +891,9 @@ sub do_text_counters {
        }
 
        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
@@ -886,7 +901,7 @@ sub do_text_counters {
                        " 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;
        }
 
@@ -912,7 +927,7 @@ sub do_text_counters {
        }
 
        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;
@@ -957,9 +972,9 @@ sub textstats_main {
        }
 
        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;
@@ -998,7 +1013,7 @@ sub textstats_main {
 #    return;
 
     if (!defined $x) { # !defined.
-       &pSReply("$arg has not said $type yet.");
+       &performStrictReply("$arg has not said $type yet.");
        return;
     }
 
@@ -1009,7 +1024,7 @@ sub textstats_main {
     }
 
     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 {