]> git.donarmstrong.com Git - infobot.git/blobdiff - blootbot/src/Factoids/Question.pl
- remove front/rear whitespaces
[infobot.git] / blootbot / src / Factoids / Question.pl
index 1347ec9c4f6cd47939ac2ccaaf59e202293c1286..03962f1ada3d260a64f5bb91d63e173defc41902 100644 (file)
@@ -35,7 +35,7 @@ sub doQuestion {
     if (!$addressed) {
        return '' unless ($finalQMark);
        return '' if (&IsParam("minVolunteerLength") == 0);
-       return '' if (length($query) < $param{'minVolunteerLength'});
+       return '' if (length $query < $param{'minVolunteerLength'});
     } else {
        ### TODO: this should be caught in Process.pl?
        return '' unless ($talkok);
@@ -43,7 +43,7 @@ sub doQuestion {
 
     # dangerous; common preambles should be stripped before here
     if ($query =~ /^forget /i or $query =~ /^no, /) {
-       return $noreply if (exists $bots{$nuh});
+       return if (exists $bots{$nuh});
     }
 
     # convert to canonical reference form
@@ -52,6 +52,11 @@ sub doQuestion {
 
     push(@query, $query);      # 1: push original.
 
+    # valid factoid.
+    if ($query =~ s/[!.]$//) {
+       push(@query,$query);
+    }
+
     $x = &normquery($query);
     push(@query, $x) if ($x ne $query);
     $query = $x;
@@ -76,16 +81,10 @@ sub doQuestion {
        $questionWord = "where";
     }
 
-    # valid factoid.
-    if ($query =~ s/[\!\.]$//) {
-       &DEBUG("Question: Pushing query without trailing symbols.");
-       push(@query,$query);
-    }
-
     for (my$i=0; $i<scalar(@query); $i++) {
-       $query = $query[$i];
+       $query  = $query[$i];
        $result = &getReply($query);
-       next if ($result eq "");
+       next if (!defined $result or $result eq "");
 
        # 'see also' factoid redirection support.
        if ($result =~ /^see( also)? (.*?)\.?$/) {
@@ -94,32 +93,33 @@ sub doQuestion {
        }
 
        if ($i != 0) {
-           &DEBUG("Question: guessed factoid correctly ($i) => '$query'.");
+           &DEBUG("Question: '$query[0]' did not exist; '$query[$i]' ($i) did");
        }
 
        return $result;
     }
 
     ### TODO: Use &Forker(); move function to Freshmeat.pl.
-    if (&IsParam("freshmeatForFactoid")) {
+    if (&IsChanConf("freshmeatForFactoid")) {
        &loadMyModule($myModules{'freshmeat'});
        $result = &Freshmeat::showPackage($query);
-       return $result unless ($result eq $noreply);
+       return $result if (defined $result);
     }
 
     ### TODO: Use &Forker(); move function to Debian.pl
-    if (&IsParam("debianForFactoid")) {
+    if (&IsChanConf("debianForFactoid")) {
        &loadMyModule($myModules{'debian'});
        $result = &Debian::DebianFind($query);  # ???
        ### TODO: debian module should tell, through shm, that it went
        ###       ok or not.
-###    return $result unless ($result eq $noreply);
+###    return $result if (defined $result);
     }
 
     if ($questionWord ne "" or $finalQMark) {
        # if it has not been explicitly marked as a question
        if ($addressed and $reply eq "") {
-           &status("notfound: <$who> ".join(' :: ', @query));
+           &status("notfound: <$who> ".join(' :: ', @query))
+                                               if ($finalQMark);
 
            return '' unless (&IsParam("friendlyBots"));
 
@@ -129,7 +129,7 @@ sub doQuestion {
        }
     }
 
-    $reply;
+    return $reply;
 }
 
 1;