]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Factoids/Update.pl
- Remaining files that were changed due to removal of $noreply or
[infobot.git] / src / Factoids / Update.pl
index 692d48dccbc3a7fa1169ac2218f69123c734f0ad..af6f4c4533d65e35ed2e1acd1b3671158425e705 100644 (file)
@@ -16,19 +16,19 @@ sub update {
     $lhs =~ s/\s+/ /g;
 
     # locked.
-    return $noreply if (&IsLocked($lhs) == 1);
+    return if (&IsLocked($lhs) == 1);
 
     # profanity.
     if (&IsParam("profanityCheck") and &hasProfanity($rhs)) {
        &msg($who, "please, watch your language.");
-       return $noreply;
+       return;
     }
 
     # teaching.
     if (&IsFlag("t") ne "t") {
        &msg($who, "permission denied.");
        &status("alert: $who wanted to teach me.");
-       return $noreply;
+       return;
     }
 
     # invalid verb.
@@ -42,7 +42,7 @@ sub update {
        length($rhs) > $param{'maxDataSize'})
     {
        &performAddressedReply("that's too long");
-       return $noreply;
+       return;
     }
 
     #
@@ -56,20 +56,34 @@ sub update {
        if (&dbGet("freshmeat", "name", $lhs, "name")) {
            &msg($who, "permission denied. (freshmeat)");
            &status("alert: $who wanted to teach me something that freshmeat already has info on.");
-           return $noreply;
+           return;
        }
     }
 
     if (my $exists = &getFactoid($lhs)) {      # factoid exists.
        if ($exists eq $rhs) {
            &performAddressedReply("i already had it that way");
-           return $noreply;
+           return;
        }
 
        if ($also) {                    # 'is also'.
            if ($also_or) {                     # 'is also ||'.
                $rhs = $exists.' || '.$rhs;
            } else {
+#              if ($exists =~ s/\,\s*$/,  /) {
+               if ($exists =~ /\,\s*$/) {
+                   &DEBUG("current has trailing comma, just append as is");
+                   # $rhs =~ s/^\s+//;
+                   # $rhs = $exists." ".$rhs;  # keep comma.
+               }
+
+               if ($exists =~ /\.\s*$/) {
+                   &DEBUG("current has trailing period, just append as is with 2 WS");
+                   # $rhs =~ s/^\s+//;
+                   # use ucfirst();?
+                   # $rhs = $exists."  ".$rhs; # keep comma.
+               }
+
                if ($rhs =~ /^[A-Z]/) {
                    if ($rhs =~ /\w+\s*$/) {
                        &status("auto insert period to factoid.");
@@ -91,8 +105,12 @@ sub update {
 
            # max length check again.
            if (length($rhs) > $param{'maxDataSize'}) {
-               &performAddressedReply("that's too long");
-               return $noreply;
+               if (length($rhs) > length($exists)) {
+                   &performAddressedReply("that's too long");
+                   return;
+               } else {
+                   &status("Update: new length is still longer than maxDataSize but less than before, we'll let it go.");
+               }
            }
 
            &performAddressedReply("okay");
@@ -101,15 +119,17 @@ sub update {
            &status("update: <$who> \'$lhs\' =$mhs=> \'$rhs\'; was \'$exists\'");
            &AddModified($lhs,$nuh);
            &setFactInfo($lhs, "factoid_value", $rhs);
+
+           if (!defined $rhs or $rhs eq "") {
+               &ERROR("Update: rhs1 == NULL.");
+           }
        } else {                                # not "also"
            if ($correction_plausible) {        # "no, blah is ..."
-               my $author = &getFactInfo($lhs, "created_by");
-
-               &DEBUG("Update: check: '$author' == '$who' ?");
+               my $author = &getFactInfo($lhs, "created_by") || "";
 
                if (IsFlag("m") ne "m" and $author !~ /^\Q$who\E\!/i) {
                    &msg($who, "you can't change that factoid.");
-                   return $noreply;
+                   return;
                }
 
                &performAddressedReply("okay");
@@ -121,12 +141,17 @@ sub update {
                &setFactInfo($lhs,"created_by", $nuh);
                &setFactInfo($lhs,"created_time", time());
                &setFactInfo($lhs,"factoid_value", $rhs);
+
+               if (!defined $rhs or $rhs eq "") {
+                   &ERROR("Update: rhs1 == NULL.");
+               }
+
            } else {                     # "blah is ..."
                if ($addressed) {
                    &performStrictReply("...but \002$lhs\002 is already something else...");
                    &status("FAILED update: <$who> \'$lhs\' =$mhs=> \'$rhs\'");
                }
-               return $noreply;
+               return;
            }
        }
     } else {                   # not exists.
@@ -146,6 +171,10 @@ sub update {
        &setFactInfo($lhs,"created_by", $nuh);
        &setFactInfo($lhs,"created_time", time());
        &setFactInfo($lhs,"factoid_value", $rhs);
+
+       if (!defined $rhs or $rhs eq "") {
+           &ERROR("Update: rhs1 == NULL.");
+       }
     }
 
     return "$lhs $mhs $rhs";