]> git.donarmstrong.com Git - infobot.git/commitdiff
added 'debianForFactoid'.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 24 Sep 2000 11:50:44 +0000 (11:50 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 24 Sep 2000 11:50:44 +0000 (11:50 +0000)
fixed question 'you suck'. found by cerb.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@138 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Question.pl

index 6b1e385da5c2f4e630462395b0102f9e0ba371e5..56a3a5317b27a574b2ee294b19eab0b538a47091 100644 (file)
@@ -23,14 +23,14 @@ sub doQuestion {
     local($reply) = "";
     local $finalQMark = $query =~ s/\?+\s*$//;
     $finalQMark += $query =~ s/\?\s*$//;
+    $query =~ s/^\s+|\s+$//g;
 
     if (!defined $query or $query =~ /^\s*$/) {
        &FIXME("doQ: query == NULL");
        return '';
     }
 
-    my $origQuery = $query;
-
+    my $origQuery      = $query;
     my $questionWord   = "";
 
     if (!$addressed) {
@@ -48,8 +48,18 @@ sub doQuestion {
     }
 
     # convert to canonical reference form
-    $query = &normquery($query);
-    $query = &switchPerson($query);
+    my $x;
+    my @query;
+
+    push(@query, $query);      # 1: push original.
+
+    $x = &normquery($query);
+    push(@query, $x) if ($x ne $query);
+    $query = $x;
+
+    $x = &switchPerson($query);
+    push(@query, $x) if ($x ne $query);
+    $query = $x;
 
     $query =~ s/\s+at\s*(\?*)$/$1/;    # where is x at?
     $query =~ s/^explain\s*(\?*)/$1/i; # explain x
@@ -67,17 +77,14 @@ sub doQuestion {
        $questionWord = "where";
     }
 
-    $query =~ s/^\s+|\s+$//g;
-
     # valid factoid.
-    my @query;
-    push(@query, $query);
     if ($query =~ s/[\!\.]$//) {
        &DEBUG("Question: Pushing query without trailing symbols.");
        push(@query,$query);
     }
 
-    foreach $query (@query) {
+    for (my$i=0; $i<scalar(@query); $i++) {
+       $query = $query[$i];
        $result = &getReply($query);
        next if ($result eq "");
 
@@ -87,6 +94,10 @@ sub doQuestion {
            $result  = $newr    if ($newr ne "");
        }
 
+       if ($i != 0) {
+           &DEBUG("Question: guessed factoid correctly ($i) => '$query'.");
+       }
+
        return $result;
     }
 
@@ -96,7 +107,15 @@ sub doQuestion {
        $result = &Freshmeat::showPackage($query);
        return $result unless ($result eq $noreply);
     }
-    &DEBUG("Question: hrm... result => '$result' for '$query'.");
+
+    ### TODO: Use &Forker(); move function to Debian.pl
+    if (&IsParam("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);
+    }
 
     if ($questionWord ne "" or $finalQMark) {
        # if it has not been explicitly marked as a question