]> git.donarmstrong.com Git - infobot.git/commitdiff
reduce sql, fix CMD: DOS
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 6 Dec 2002 21:42:50 +0000 (21:42 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 6 Dec 2002 21:42:50 +0000 (21:42 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@731 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Question.pl
src/Factoids/Update.pl

index 5a0ddb299c5d7ddd62ca16fb7c1939f0e7d03d25..04dd157d9d2932a3255a13f9cb0801c9c4cc02f1 100644 (file)
@@ -182,7 +182,8 @@ sub factoidArgs {
     # which will make it less than linear => quicker!
     # todo: cache this, update cache when altered. !!! !!! !!!
 #    my $t = &timeget();
-    my @list = &searchTable("factoids", "factoid_key", "factoid_key", "^CMD: ");
+    my ($first) = split(/\s+/, $str); 
+    my @list = &searchTable("factoids", "factoid_key", "factoid_key", "^CMD: $first ");
 #    my $delta_time = &timedelta($t);
 #    &DEBUG("factArgs: delta_time = $delta_time s");
 #    &DEBUG("factArgs: list => ".scalar(@list) );
index 322f501e0a924123db57da745ffd62693ae0a939..3de1ad7c0674ac4b60b81a80b2be80081f41025f 100644 (file)
@@ -63,7 +63,8 @@ sub update {
     }
 
     # factoid arguments handler.
-    if (&IsChanConf("factoidArguments") and $lhs =~ /\$/) {
+    # must start with a non-variable
+    if (&IsChanConf("factoidArguments") and $lhs =~ /^[^\$]+.*\$/) {
        &status("Update: Factoid Arguments found.");
        &status("Update: orig lhs => '$lhs'.");
        &status("Update: orig rhs => '$rhs'.");
@@ -79,16 +80,14 @@ sub update {
 
        if ($count >= 10) {
            &msg($who, "error: could not SAR properly.");
-           &DEBUG("error: lhs => '$lhs'.");
-           &DEBUG("error: rhs => '$rhs'.");
+           &DEBUG("error: lhs => '$lhs' rhs => '$rhs'.");
            return;
        }
 
        my $z = join(',',@list);
        $rhs =~ s/^/($z): /;
 
-       &status("Update: new  lhs => '$lhs'.");
-       &status("Update: new  rhs => '$rhs'.");
+       &status("Update: new lhs => '$lhs' rhs => '$rhs'.");
     }
 
     # the fun begins.
@@ -189,8 +188,12 @@ sub update {
 
        $count{'Update'}++;
        &status("update: <$who> \'$lhs\' =$mhs=> \'$rhs\'; was \'$exists\'");
-       &AddModified($lhs,$nuh);
-       &setFactInfo($lhs, "factoid_value", $rhs);
+       &sqlReplace("factoids", {
+               factoid_key     => $lhs,
+               modified_by     => $nuh,
+               modified_time   => time(),
+               factoid_value   => $rhs,
+       } );
 
        if (!defined $rhs or $rhs eq "") {
            &ERROR("Update: rhs1 == NULL.");
@@ -219,11 +222,12 @@ sub update {
        $count{'Update'}++;
        &status("update: <$who> \'$lhs\' =$mhs=> \'$rhs\'; was \'$exists\'");
 
-       # todo: use sqlReplace.
-       #&delFactoid($lhs); # breaks dbm. leave it and use modified_* - Tim Riker <Tim@Rikers.org>
-       &setFactInfo($lhs,"modified_by", $nuh);
-       &setFactInfo($lhs,"modified_time", time());
-       &setFactInfo($lhs,"factoid_value", $rhs);
+       &sqlReplace("factoids", {
+               factoid_key     => $lhs,
+               modified_by     => $nuh,
+               modified_time   => time(),
+               factoid_value   => $rhs,
+       } );
 
        if (!defined $rhs or $rhs eq "") {
            &ERROR("Update: rhs1 == NULL.");