From 5bb02bbc30d16fac5b2f572679d854bcb2d17130 Mon Sep 17 00:00:00 2001 From: timriker Date: Fri, 6 Dec 2002 21:42:50 +0000 Subject: [PATCH] reduce sql, fix CMD: DOS git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@731 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Factoids/Question.pl | 3 ++- src/Factoids/Update.pl | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Factoids/Question.pl b/src/Factoids/Question.pl index 5a0ddb2..04dd157 100644 --- a/src/Factoids/Question.pl +++ b/src/Factoids/Question.pl @@ -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) ); diff --git a/src/Factoids/Update.pl b/src/Factoids/Update.pl index 322f501..3de1ad7 100644 --- a/src/Factoids/Update.pl +++ b/src/Factoids/Update.pl @@ -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 - &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."); -- 2.39.2