}
# also checking.
- my $also = ($rhs =~ s/^(-?)also //i);
- &DEBUG("1=>$1");
+ my $also = ($rhs =~ s/^-?also //i);
my $also_or = ($also and $rhs =~ s/\s+(or|\|\|)\s+//);
# freshmeat
if (&IsChanConf("freshmeatForFactoid")) {
- if (&dbGet("freshmeat", "name", $lhs, "name")) {
+ # todo: "name" is invalid for fm ][
+ if ( &dbGet("freshmeat", "name", "name=".&dbQuote($lhs)) ) {
&msg($who, "permission denied. (freshmeat)");
&status("alert: $who wanted to teach me something that freshmeat already has info on.");
return 1;
}
}
+ # factoid arguments handler.
+ if (&IsChanConf("factoidArguments") and $lhs =~ /\$/) {
+ &status("Update: Factoid Arguments found.");
+ &status("Update: orig lhs => '$lhs'.");
+ &status("Update: orig rhs => '$rhs'.");
+
+ my @list;
+ my $count = 0;
+ $lhs =~ s/^/CMD: /;
+ while ($lhs =~ s/\$(\S+)/(.*?)/) {
+ push(@list, "\$$1");
+ $count++;
+ last if ($count >= 10);
+ }
+
+ if ($count >= 10) {
+ &msg($who, "error: could not SAR properly.");
+ &DEBUG("error: lhs => '$lhs'.");
+ &DEBUG("error: rhs => '$rhs'.");
+ return;
+ }
+
+ my $z = join(',',@list);
+ $rhs =~ s/^/($z): /;
+
+ &status("Update: new lhs => '$lhs'.");
+ &status("Update: new rhs => '$rhs'.");
+ }
+
# the fun begins.
my $exists = &getFactoid($lhs);
if (!$exists) {
# nice 'are' hack (or work-around).
if ($mhs =~ /^are$/i and $rhs !~ /<\S+>/) {
- &DEBUG("Update: 'are' hack detected.");
+ &status("Update: 'are' hack detected.");
$mhs = "is";
$rhs = "<REPLY> are ". $rhs;
}
&performAddressedReply("okay");
- &setFactInfo($lhs,"created_by", $nuh);
- &setFactInfo($lhs,"created_time", time());
- &setFactInfo($lhs,"factoid_value", $rhs);
+ if (1) { # old
+ &setFactInfo($lhs,"factoid_value", $rhs);
+ &setFactInfo($lhs,"created_by", $nuh);
+ &setFactInfo($lhs,"created_time", time());
+ } else {
+ ### BROKEN!!!
+ # I'd prefer to use dbReplace but it don't work.
+ &dbReplace("factoids", (
+ factoid_key => $lhs,
+ created_by => time(),
+ factoid_value => $rhs,
+ ) );
+ }
if (!defined $rhs or $rhs eq "") {
&ERROR("Update: rhs1 == NULL.");
# if ($exists =~ s/\,\s*$/, /) {
if ($exists =~ /\,\s*$/) {
&DEBUG("current has trailing comma, just append as is");
+ &DEBUG("Up: exists => $exists");
+ &DEBUG("Up: rhs => $rhs");
# $rhs =~ s/^\s+//;
# $rhs = $exists." ".$rhs; # keep comma.
}
if ($exists =~ /\.\s*$/) {
&DEBUG("current has trailing period, just append as is with 2 WS");
+ &DEBUG("Up: exists => $exists");
+ &DEBUG("Up: rhs => $rhs");
# $rhs =~ s/^\s+//;
# use ucfirst();?
# $rhs = $exists." ".$rhs; # keep comma.
&performStrictReply("...but \002$lhs\002 is already something else...");
&status("FAILED update: <$who> \'$lhs\' =$mhs=> \'$rhs\'");
}
- return;
+ return 1;
}
my $author = &getFactInfo($lhs, "created_by") || "";