]> git.donarmstrong.com Git - infobot.git/commitdiff
- make ignoreAdd a little more verbose.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 26 Dec 2001 11:51:20 +0000 (11:51 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 26 Dec 2001 11:51:20 +0000 (11:51 +0000)
- added factoidPreventForgetLimitTime. if a factoid exceeds this age,
  prevent forget.
- added factoidPreventForgetRedirect. if this factoid is redirected to
  by other factoids, prevent forget.
- don't evaluate dollar vars in factoid request if it's a factoid
  command.

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

src/DynaConfig.pl
src/Factoids/Core.pl
src/Factoids/Reply.pl
src/Modules/Factoids.pl
src/Modules/News.pl

index b76e7579763d94f8bbf519822a8c75ccf0ea4e97..e24b0d41122a19b80b31b53e2298f989151e9fe6 100644 (file)
@@ -513,6 +513,9 @@ sub ignoreAdd {
 
     $ignore{$chan}{$mask} = [$expire, time(), $who, $comment];
 
+    # todo: improve this.
+    &status("ignore: Added $mask for $chan to expire $expire, by $who, for $comment");
+
     if ($exist) {
        $utime_userfile = time();
        $ucount_userfile++;
index d8d559a0a8b2202a5afc1521f16f174314c1113b..067e49428e3c8d399f71737093c265c6c6d99d78 100644 (file)
@@ -148,8 +148,11 @@ sub FactoidStuff {
        if (defined $result) {
            my $author  = &getFactInfo($faqtoid, "created_by");
            my $count   = &getFactInfo($faqtoid, "requested_count") || 0;
-           my $limit   = &getChanConfDefault("factoidPreventForgetLimit", 
-                               100, $chan);
+           my $limit   = &getChanConfDefault(
+                               "factoidPreventForgetLimit", 100, $chan);
+           my $limitage = &getChanConfDefault(
+                               "factoidPreventForgetLimitTime", 180, $chan);
+           my $age     = time() - &getFactInfo($faqtoid, "created_time");
 
            if (IsFlag("r") ne "r") {
                &msg($who, "you don't have access to remove factoids");
@@ -157,16 +160,52 @@ sub FactoidStuff {
            }
 
            return 'locked factoid' if (&IsLocked($faqtoid) == 1);
+           my $isop = (&IsFlag("o") eq "o") ? 1 : 0;
+
+           ### lets go do some checking.
+
+           # factoidPreventForgetLimitTime:
+           if (!$isop and $age/(60*60*24) > $limitage) {
+               &msg($who, "cannot remove factoid since it is protected by Time.");
+               return;
+           }
 
            # factoidPreventForgetLimit:
-           if ($limit and $count > $limit and (&IsFlag("o") ne "o")) {
+           if (!$isop and $limit and $count > $limit) {
                &msg($who, "will not delete '$faqtoid', count > limit ($count > $limit)");
                return;
            }
 
-           # prevent/minimize abuse.
+           # this may eat some memory.
+           # prevent deletion if other factoids redirect to it.
+           # todo: use hash instead of array.
+           my @list;
+           if (&getChanConf("factoidPreventForgetRedirect")) {
+               &status("Factoids/Core: forget: checking for redirect factoids");
+               @list = &searchTable("factoids", "factoid_key",
+                               "factoid_value", "^<REPLY> see ");
+           }
+
+           my $match = 0;
+           for (@list) {
+               my $f = $_;
+               my $v = &getFactInfo($f, "factoid_value");
+               my $fsafe = quotemeta($faqtoid);
+               next unless ($v =~ /^<REPLY> ?see( also)? $fsafe\.?$/i);
+
+               &DEBUG("Factoids/Core: match! ($f || $faqtoid)");
+
+               $match++;
+           }
+           # todo: warn for op aswell, but allow force delete.
+           if (!$isop and $match) {
+               &msg($who, "uhm, other (redirection) factoids depend on this one.");
+               return;
+           }
+
+           # minimize abuse.
            my $faqauth = &getFactInfo($faqtoid, "created_by");
-           if (&IsFlag("o") ne "o" and &IsHostMatch($faqauth) != 2) {
+           if (!$isop and &IsHostMatch($faqauth) != 2) {
                $cache{forget}{$h}++;
 
                # warn.
@@ -186,7 +225,7 @@ sub FactoidStuff {
            # lets do it!
 
            if (&IsParam("factoidDeleteDelay") or &IsChanConf("factoidDeleteDelay")) {
-               if ($faqtoid =~ / #DEL#$/ and !&IsFlag("o")) {
+               if (!$isop and $faqtoid =~ / #DEL#$/) {
                    &msg($who, "cannot delete it ($faqtoid).");
                    return;
                }
index e73a73e254b6e4eb3079652dcdcb970d75168d25..5c472fc5b87f257090670bcfb9888aee7da6042a 100644 (file)
@@ -136,9 +136,12 @@ sub getReply {
     ### $ SUBSTITUTION.
     ###
 
-#    &DEBUG("Reply: reply => $reply");
-    $reply = &substVars($reply,1);
-#    &DEBUG("Reply: reply => $reply");
+    # don't evaluate if it has factoid arguments.
+    if ($message =~ /^CMD:/i) {
+       &status("Reply: not doing substVars (eval dollar vars)");
+    } else {
+       $reply = &substVars($reply,1);
+    }
 
     $reply;
 }
index caadae6856a1c36fef09cc893623bed989782a8e..f00bdaabc2de9216a50eb29050ca2dea626151d5 100644 (file)
@@ -271,7 +271,7 @@ sub CmdFactStats {
        for (@list) {
            my $factoid = $_;
            my $val = &getFactInfo($factoid, "factoid_value");
-           if ($val =~ /^<REPLY> see( also)? (.*?)\.?$/i) {
+           if ($val =~ /^<REPLY> ?see( also)? (.*?)\.?$/i) {
                my $redirf = lc $2;
                my $redir = &getFactInfo($redirf, "factoid_value");
                next if (defined $redir);
index c9a8fddbdc64bda9033ac5b669a6403f6dc4c875..6acebdb2759525ac3df9f4b1c8ceb86327a9daf1 100644 (file)
@@ -442,6 +442,15 @@ sub read {
 
     my $item   = &getNewsItem($str);
     if (!defined $item or !scalar keys %{ $::news{$chan}{$item} }) {
+       # todo: numerical check.
+       if ($str =~ /^(\d+) (\d+)$/ or
+           $str =~ /^(\d+)-(\d+)$/ or
+           $str =~ /^-(\d+)$/ or $str =~ /^(\d+)-$/ or 0
+       ) {
+           &::notice($who, "We don't support multiple requests of news items, sorry.");
+           return;
+       }
+
        &::notice($who, "No news item called '$str'");
        return;
     }