]> git.donarmstrong.com Git - infobot.git/commitdiff
- Finally added proper recursive SARs
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 3 Jan 2001 13:37:00 +0000 (13:37 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 3 Jan 2001 13:37:00 +0000 (13:37 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@220 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Reply.pl

index d0607c17c47013a485a64f36738ed03efa671429..0ad9ecca198bd9b3f0f9a50f8adac3e6451ceabf 100644 (file)
@@ -86,9 +86,32 @@ sub getReply {
        $done = 0;
 
        # EG: (blah1|blah2|blah3|) => blah1
-       while ($result =~ /\((.*?\|.*?)\)/) {
+       while ($result =~ /\((.*\|.*?)\)/) {
            my $str = $1;
-           my @rand = split /\|/, $str;
+           my @rand;
+
+           if ($done == 1) {
+               &status("Cool. recursive SAR factoids rock :-)");
+           }
+
+           my $x = "";
+           foreach (split /\|/, $str) {
+               $x = $x.$_;
+
+               if (/^\(/ or ($x ne $_ and !/\)$/)) {   # start or mid.
+                   $x = $x."|";
+###                print "start or mid. ($x)\n";
+               } elsif (/\)$/) {               # end.
+###                print "end; pushing '$x$_', (was $x)\n";
+                   push(@rand,$x);
+                   $x = "";
+               } else {
+###                print "nice append. '$_'\n";
+                   push(@rand,$_);
+                   $x = "";
+               }
+           }
+
            my $rand = $rand[rand @rand];
 
            &status("Reply.pl: SARing '($str)' to '$rand'.");