# 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) );
}
# 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'.");
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.
$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.");
$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.");