]> git.donarmstrong.com Git - infobot.git/blobdiff - src/CommandStubs.pl
ws
[infobot.git] / src / CommandStubs.pl
index 0a37f7ca514693cfff9a47a1476f331ef5c5345b..7da444ec790176150a434ec4afa892d43285a9a2 100644 (file)
@@ -18,7 +18,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 +44,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 +74,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) {
@@ -183,13 +184,13 @@ sub parseCmdHook {
 &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", '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', 
+       'Identifier' => 'search', Module => 'factoids',
        'Help' => 'listauth') );
 &addCmdHook("extra", 'quote', ('CODEREF' => 'Quote::Quote',
        'Forker' => 1, 'Identifier' => 'quote',
@@ -247,6 +248,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 +282,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 +299,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); } );
@@ -308,10 +312,8 @@ sub Modules {
     my $itc;
     $itc = &getChanConf("ircTextCounters");
     $itc = &findChanConf("ircTextCounters") unless ($itc);
-    if ($itc) {
-       &do_text_counters($itc);
-       return;
-    }
+    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) {
@@ -543,7 +545,7 @@ sub seen {
            $reply .= " (".&Time2String(time() - $userstats{lc $seen[0]}{'Join'}).")";
        }
 
-       if (&IsParam("seenStats")) {
+       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);
@@ -820,7 +822,7 @@ sub do_text_counters {
 
     if ($message =~ /^_stats(\s+(\S+))$/i) {
        &textstats_main($2);
-       return;
+       return 1;
     }
 
     my ($type,$arg);
@@ -828,7 +830,7 @@ sub do_text_counters {
        $type = $1;
        $arg  = $3;
     } else {
-       return;
+       return 0;
     }
 
     # even more uglier with channel/time arguments.
@@ -882,7 +884,7 @@ sub do_text_counters {
 
        if (!defined $x) {      # !defined.
            &pSReply("$arg has not said $type yet.");
-           return;
+           return 1;
        }
 
        # defined.
@@ -910,10 +912,7 @@ sub do_text_counters {
        &pSReply("\002$arg\002 has said \037$type\037 \002$x\002 times (\002$pct1\002 %)$xtra");
     }
 
-    if ($@) {
-       &DEBUG("regex failed: $@");
-       return;
-    }
+    return 1;
 }
 
 sub textstats_main {