]> git.donarmstrong.com Git - infobot.git/commitdiff
fixed/added global factoid SAR
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 9 Sep 2000 16:16:47 +0000 (16:16 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 9 Sep 2000 16:16:47 +0000 (16:16 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@77 c11ca15a-4712-0410-83d8-924469b57eb5

src/Modules/UserDCC.pl

index 8337c952d09f12377dfb3f7ecfa757a1a902008d..c615410e6821dc25e3e3deb1e50a0f8ddd586173 100644 (file)
@@ -340,14 +340,14 @@ sub userDCC {
     }
 
     # global factoid substitution.
-    if ($message =~ m|^s([/,#])(.+?)\2(.*?)\2;?\s*$|) {
-       &DEBUG("global factoid subst called!");
+    if ($message =~ m|^s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
        my ($delim,$op,$np) = ($1, $2, $3);
        return $noreply unless (&hasFlag("n"));
+       ### TODO: support flags to do full-on global.
 
        # incorrect format.
        if ($np =~ /$delim/) {
-           &msg($who,"looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
+           &performReply("looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
            return $noreply;
        }
 
@@ -357,10 +357,18 @@ sub userDCC {
                        "factoid_value", $op);
 
        if (!scalar @list) {
-           &performStrictReply("Expression didn't match anything.");
+           &performReply("Expression didn't match anything.");
            return $noreply;
        }
 
+       if (scalar @list > 100) {
+           &performReply("regex found more than 100 matches... not doing.");
+           return $noreply;
+       }
+
+       &status("gsubst: going to alter ".scalar(@list)." factoids.");
+       &performReply("going to alter ".scalar(@list)." factoids.");
+
        my $error = 0;
        foreach (@list) {
            my $faqtoid = $_;
@@ -377,7 +385,7 @@ sub userDCC {
                    &performReply("that's too long (or was long)");
                    return $noreply;
                }
-###            &setFactInfo($faqtoid, "factoid_value", $result);
+               &setFactInfo($faqtoid, "factoid_value", $result);
                &status("update: '$faqtoid' =is=> '$result'; was '$was'");
            } else {
                &WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
@@ -386,9 +394,12 @@ sub userDCC {
        }
 
        if ($error) {
-           &ERROR("Something happened...");
+           &ERROR("Some warnings/errors?");
        }
 
+       &performReply("Ok... did s/$op/$np/ for ".
+                               (scalar(@list) - $error)." factoids");
+
        return $noreply;
     }
 
@@ -424,7 +435,7 @@ sub userDCC {
 
        &status("USER reload $who");
        &msg($who,"reloading...");
-       &reloadModules();
+       &reloadAllModules();
        &msg($who,"reloaded.");
 
        return $noreply;