]> git.donarmstrong.com Git - infobot.git/commitdiff
- recursive factoid linking added.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 20 Feb 2001 13:01:29 +0000 (13:01 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 20 Feb 2001 13:01:29 +0000 (13:01 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@412 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Question.pl

index 03962f1ada3d260a64f5bb91d63e173defc41902..e6b0818fd88794ebcb0418654993adc6115f4956 100644 (file)
@@ -81,17 +81,36 @@ sub doQuestion {
        $questionWord = "where";
     }
 
+    my @link;
     for (my$i=0; $i<scalar(@query); $i++) {
        $query  = $query[$i];
        $result = &getReply($query);
        next if (!defined $result or $result eq "");
 
        # 'see also' factoid redirection support.
-       if ($result =~ /^see( also)? (.*?)\.?$/) {
-           my $newr = &getReply($2);
+
+       while ($result =~ /^see( also)? (.*?)\.?$/) {
+           my $link    = $2;
+
+           if (grep /^$link$/i, @link) {
+               &status("recursive link found; bailing out.");
+               last;
+           }
+
+           if (scalar @link >= 5) {
+               &status("recursive link limit reached.");
+               last;
+           }
+
+           push(@link, $link);
+           my $newr = &getReply($link);
            $result  = $newr    if ($newr ne "");
        }
 
+       if (@link) {
+           &status("'$query' linked to: ".join(" => ", @link) );
+       }
+
        if ($i != 0) {
            &DEBUG("Question: '$query[0]' did not exist; '$query[$i]' ($i) did");
        }