]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Factoids/Question.pl
- converted 3 instances of setFactInfo to 1 sqlUpdate.
[infobot.git] / src / Factoids / Question.pl
index c51ec75b90c51019dbe1434c0e4261769089aaff..2338e4454cd58533d1e227a92915ff79c05d52df 100644 (file)
@@ -11,7 +11,7 @@
 ##
 ##
 
-if (&IsParam("useStrict")) { use strict; }
+# use strict;  # TODO
 
 use vars qw($query $reply $finalQMark $nuh $result $talkok $who $nuh);
 use vars qw(%bots %forked);
@@ -109,13 +109,17 @@ sub doQuestion {
        while ($result =~ /^see( also)? (.*?)\.?$/) {
            my $link    = $2;
 
-           if (grep /^$link$/i, @link) {
+           # #debian@OPN was having problems with libstdc++ factoid
+           # redirection :) 20021116. -xk.
+           # hrm... allow recursive loops... next if statement handles
+           # that.
+           if (grep /^\Q$link\E$/i, @link) {
                &status("recursive link found; bailing out.");
                last;
            }
 
            if (scalar @link >= 5) {
-               &status("recursive link limit reached.");
+               &status("recursive link limit (5) reached.");
                last;
            }
 
@@ -190,7 +194,7 @@ sub factoidArgs {
        next if (/#DEL#/);      # deleted.
 
        s/^CMD: //i;
-#      &DEBUG("factarg: ''$str' =~ /^$_\$/'");
+#      &DEBUG("factarg: '$str' =~ /^$_\$/");
        my $arg = $_;
 
        # todo: <greycat> ~punish apt for (Eating) (Parentheses)
@@ -227,11 +231,20 @@ sub factoidArgs {
        }
 
        # update stats.
-       my $count = &getFactInfo($q, "requested_count") || 0;
-       $count++;
-       &setFactInfo($q, "requested_by", $nuh);
-       &setFactInfo($q, "requested_time", time());
-       &setFactInfo($q, "requested_count", $count);
+       if (0) {        # old.
+           my $count = &getFactInfo($q, "requested_count") || 0;
+           $count++;
+           &setFactInfo($q, "requested_by", $nuh);
+           &setFactInfo($q, "requested_time", time());
+           &setFactInfo($q, "requested_count", $count);
+       } else {
+           &sqlUpdate("factoids", { factoid_key => $q }, {
+               requested_by            => $nuh,
+               requested_time          => time(),
+               -requested_count        => "requested_count+1",
+           } );
+       }
+
        # end of update stats.
 
        $result = $r;