]> git.donarmstrong.com Git - infobot.git/commitdiff
- return early if $AUTOLOAD is undefined.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 11 Dec 2001 16:40:18 +0000 (16:40 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 11 Dec 2001 16:40:18 +0000 (16:40 +0000)
- set factoidPreventForgetLimit default to 100
- added abuse prevention of forget. (lets thank lazarus)
- backup of factoids was not working - fixed!
- factoid sar now has protection against all-out (>=2x) removal.
- added global $h var for host.
- commented out some news debugging since we hopefully fixed $who
  case-sensitivity.

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

src/Factoids/Core.pl
src/IRC/IrcHooks.pl
src/Modules/News.pl
src/modules.pl

index ec0addb8f1b97d10b3891caa19c9bb9e3b2406af..5a473d4ab70442263b2c30d5cd60883fef35f500 100644 (file)
@@ -149,10 +149,7 @@ sub FactoidStuff {
            my $author  = &getFactInfo($faqtoid, "created_by");
            my $count   = &getFactInfo($faqtoid, "requested_count") || 0;
            my $limit   = &getChanConfDefault("factoidPreventForgetLimit", 
-                               0, $chan);
-
-           &DEBUG("forget: limit = $limit");
-           &DEBUG("forget: count = $count");
+                               100, $chan);
 
            if (IsFlag("r") ne "r") {
                &msg($who, "you don't have access to remove factoids");
@@ -167,13 +164,34 @@ sub FactoidStuff {
                return;
            }
 
+           # prevent/minimize abuse.
+           my $faqauth = &getFactInfo($faqtoid, "created_by");
+           if (&IsFlag("o") ne "o" and &IsHostMatch($faqauth) != 2) {
+               $cache{forget}{$h}++;
+
+               # warn.
+               if ($cache{forget}{$h} > 3) {
+                   &msg($who, "Stop abusing forget!");
+               }
+
+               # ignore.
+               # todo: make forget limit configurable.
+               # todo: make forget ignore time configurable.
+               if ($cache{forget}{$h} > 5) {
+                   &ignoreAdd($mask{nuh}, "*", 3*24*60*60, "abuse of forget");
+                   &msg($who, "forget: Suck it!");
+               }
+           }
+
+           # lets do it!
+
            if (&IsParam("factoidDeleteDelay") or &IsChanConf("factoidDeleteDelay")) {
                if ($faqtoid =~ / #DEL#$/ and !&IsFlag("o")) {
                    &msg($who, "cannot delete it ($faqtoid).");
                    return;
                }
 
-               &status("forgot (safe delete): <$who> '$faqtoid' =is=> '$result'");
+               &status("forgot (safe delete): '$faqtoid' - ". scalar(localtime));
                ### TODO: check if the "backup" exists and overwrite it
                my $check = &getFactoid("$faqtoid #DEL#");
 
@@ -181,8 +199,7 @@ sub FactoidStuff {
                    if ($faqtoid !~ / #DEL#$/) {
                        my $new = $faqtoid." #DEL#";
 
-                       my $backup = &getFactoid($faqtoid);
-                       # this looks weird but does it work?
+                       my $backup = &getFactoid($new);
                        if ($backup) {
                            &DEBUG("forget: not overwriting backup: $faqtoid");
                        } else {
@@ -199,15 +216,15 @@ sub FactoidStuff {
                } else {
                    &status("forget: not overwriting backup!");
                }
-
-           } else {
-               &status("forget: <$who> '$faqtoid' =is=> '$result'");
            }
+
+           &status("forget: <$who> '$faqtoid' =is=> '$result'");
            &delFactoid($faqtoid);
 
            &performReply("i forgot $faqtoid");
 
            $count{'Update'}++;
+
        } else {
            &performReply("i didn't have anything called '$faqtoid'");
        }
@@ -238,12 +255,12 @@ sub FactoidStuff {
        my $check  = &getFactoid($faqtoid);
 
        if (!defined $result) {
-           &performReply("i didn't have anything ('$faqtoid') to undelete.");
+           &performReply("that factoid was not backedup :/");
            return;
        }
 
        if (defined $check) {
-           &performReply("cannot undeleted '$faqtoid' because it already exists?");
+           &performReply("cannot undeleted '$faqtoid' because it already exists!");
            return;
        }
 
@@ -350,10 +367,20 @@ sub FactoidStuff {
            my $was = $result;
 
            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;
                }
+               # min length.
+               my $faqauth = &getFactInfo($faqtoid, "created_by");
+               if ((length $result)*2 < length $was and
+                       &IsFlag("o") ne "o" and
+                       &IsHostMask($faqauth) != 2
+               ) {
+                   &performReply("too drastic change of factoid.");
+               }
+
                &setFactInfo($faqtoid, "factoid_value", $result);
                &status("update: '$faqtoid' =is=> '$result'; was '$was'");
                &performReply("OK");
index 1a77e32a3ce2ee3480072faaa030b8cdde51dfd6..9c0dcdc7639393a40c943ad869db37d5977cab61 100644 (file)
@@ -55,6 +55,7 @@ sub on_chat {
     $orig{message}     = $msg;
     $nuh               = $nuh{$who};
     $uh                        = (split /\!/, $nuh)[1];
+    $h                 = (split /\@/, $uh)[1];
     $addressed         = 1;
     $msgType           = 'chat';
 
index 7bf24a5439f2d6e997070da6c6a8cda7fdfc94bd..2942f851348b5e57a15e7b5d8127efcb1a3ee7d6 100644 (file)
@@ -713,11 +713,11 @@ sub latest {
     }
 
     my $t = $::newsuser{$chan}{$who};
-    if (defined $t) {
-       &::DEBUG("newsuser: $chan/$who == $t");
-    } else {
-       &::DEBUG("newsuser: $chan/$who == undefined");
-    }
+#    if (defined $t) {
+#      &::DEBUG("newsuser: $chan/$who == $t");
+#    } else {
+#      &::DEBUG("newsuser: $chan/$who == undefined");
+#    }
 
     if (defined $t and ($t == 0 or $t == -1)) {
        if ($flag) {
index e55f01570f1742fa86d6d9585a7b7587668f6742..224db3ac1f30e973673a8ae86a93427b9c856ddd 100644 (file)
@@ -362,6 +362,10 @@ if ($@) {
 &showProc(" (Time::HiRes)");
 
 sub AUTOLOAD {
+    if (defined $::AUTOLOAD) {
+       &DEBUG("AUTOLOAD: hrm.. ::AUTOLOAD defined!");
+    }
+    return unless (defined $AUTOLOAD);
     return if ($AUTOLOAD =~ /__/);     # internal.
 
     my $str = join(', ', @_);