]> git.donarmstrong.com Git - infobot.git/commitdiff
* Fixed bug in factoid modification code that prevented matching against created_by...
authordjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 16 Apr 2008 01:41:43 +0000 (01:41 +0000)
committerdjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 16 Apr 2008 01:41:43 +0000 (01:41 +0000)
* New +M flag to allow modifying factoids created by same nick
* Added +M to help file
* Released 1.5.1

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1659 c11ca15a-4712-0410-83d8-924469b57eb5

ChangeLog
VERSION
files/infobot.help
src/Factoids/Core.pl

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..543f0758885b54caee8b17e8aaba91d848cb223b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,7 @@
+1.5.1
+=====
+
+* Fixed bug in factoid modification code that prevented matching against
+created_by properly
+
+* New +M flag to allow modifying factoids created by same nick
diff --git a/VERSION b/VERSION
index bc80560fad66ca670bdfbd1e5c973a024d4d0325..26ca594609a93d60b6543102d639fa76b50a6925 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.5.0
+1.5.1
index c0370ee9f3fd8ce0c8b7bbd2ccb9954949b1925e..53e2b16e2bfae026d8ee938e6b7bf1914b542b9e 100644 (file)
@@ -474,7 +474,8 @@ flags: D: "A" - bot administration over /msg (default is only via DCC CHAT)
 flags: D: "O" - dynamic ops (as on channel). (automatic +o)
 flags: D: "T" - add topics.
 flags: D: "a" - ask/request factoid.
-flags: D: "m" - modify factoid. (includes renaming)
+flags: D: "m" - modify all factoids. (includes renaming)
+flags: D: "M" - modify own factoids. (includes renaming)
 flags: D: "n" - bot owner, can "reload"
 flags: D: "o" - master of bot (automatic +amrt)
 flags: D:        - can search on factoid strings shorter than 2 chars
index 4898008d810320038b6f0f9c973e9f02c7a3701e..dbf2d469ce9a4b906c39a85ba7cb39ea14eb3988 100644 (file)
@@ -383,11 +383,26 @@ sub FactoidStuff {
                return;
            }
 
-           # who == nick!user@host.
-           if (&IsFlag('m') ne 'm' and $author !~ /^\Q$who\E\!/i) {
-               &msg($who, "factoid '$from' is not yours to modify.");
-               return;
-           }
+           # author == nick!user@host
+        # created_by == nick
+        my $author  = &getFactInfo($from, 'created_by');
+        $author =~ /^(.*)!/;
+        my $created_by = $1;
+
+        # Can they even modify factoids?
+        if (&IsFlag('m') ne 'm' and &IsFlag('M') ne 'M' and &IsFlag('o') ne 'o') {
+            &performReply("You do not have permission to modify factoids");
+            return;
+
+        # If they have +M but they didnt create the factoid
+        } elsif (&IsFlag('M') eq 'M' and
+                 $who !~ /^\Q$created_by\E$/i
+                 &IsFlag('m') ne 'm'
+                 &IsFlag('o') ne 'o') {
+            &performReply("factoid '$from' is not yours to modify.");
+            return;
+        }
+        # Else they have permission, so continue
 
            if ($_ = &getFactoid($to)) {
                &performReply("destination factoid already exists.");
@@ -420,36 +435,56 @@ sub FactoidStuff {
        if (my $result = &getFactoid($faqtoid)) {
            return 'subst: locked' if (&IsLocked($faqtoid) == 1);
            my $was = $result;
+        my $faqauth = &getFactInfo($faqtoid, 'created_by');
 
            if (($flags eq 'g' && $result =~ s/\Q$op/$np/gi) || $result =~ s/\Q$op/$np/i) {
-               # excessive length.
-               if (length $result > $param{'maxDataSize'}) {
-                   &performReply("that's too long");
-                   return;
-               }
-               # empty
-               if (length $result == 0) {
-                   &performReply("factoid would be empty. use forget?");
-                   return;
-               }
-               # min length.
-               my $faqauth = &getFactInfo($faqtoid, 'created_by');
-               if ((length $result)*2 < length $was and
-                       &IsFlag('o') ne 'o' and
-                       &IsHostMatch($faqauth) != 2
-               ) {
-                   &performReply("too drastic change of factoid.");
-               }
-
-               &setFactInfo($faqtoid, 'factoid_value', $result);
-               &status("update: '$faqtoid' =is=> '$result'; was '$was'");
-               &performReply('OK');
-           } else {
-               &performReply("that doesn't contain '$op'");
-           }
-       } else {
-           &performReply("i didn't have anything called '$faqtoid' to modify");
-       }
+            my $author = $faqauth;
+            $author =~ /^(.*)!/;
+            my $created_by = $1;
+
+            # Can they even modify factoids?
+            if (&IsFlag('m') ne 'm' and &IsFlag('M') ne 'M' and &IsFlag('o') ne 'o') {
+                &performReply("You do not have permission to modify factoids");
+                return;
+
+            # If they have +M but they didnt create the factoid
+            } elsif (&IsFlag('M') eq 'M' and
+                     $who !~ /^\Q$created_by\E$/i
+                     &IsFlag('m') ne 'm'
+                     &IsFlag('o') ne 'o') {
+                &performReply("factoid '$faqtoid' is not yours to modify.");
+                return;
+            }
+
+                   # excessive length.
+                   if (length $result > $param{'maxDataSize'}) {
+                       &performReply("that's too long");
+                       return;
+                   }
+            
+            # empty
+            if (length $result == 0) {
+                &performReply("factoid would be empty. Use forget instead.");
+                return;
+            }
+
+            # min length.
+            if ((length $result)*2 < length $was and
+                &IsFlag('o') ne 'o' and
+                &IsHostMatch($faqauth) != 2
+            ) {
+                &performReply("too drastic change of factoid.");
+            }
+
+            &setFactInfo($faqtoid, 'factoid_value', $result);
+            &status("update: '$faqtoid' =is=> '$result'; was '$was'");
+            &performReply('OK');
+            } else {
+                &performReply("that doesn't contain '$op'");
+            }
+        } else {
+            &performReply("i didn't have anything called '$faqtoid' to modify");
+        }
 
        return;
     }