From 498a586c0a513057db37325cc8f9f528d972eeff Mon Sep 17 00:00:00 2001 From: dms Date: Tue, 11 Dec 2001 16:40:18 +0000 Subject: [PATCH] - return early if $AUTOLOAD is undefined. - 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@530 c11ca15a-4712-0410-83d8-924469b57eb5 --- blootbot/src/Factoids/Core.pl | 51 ++++++++++++++++++++++++++--------- blootbot/src/IRC/IrcHooks.pl | 1 + blootbot/src/Modules/News.pl | 10 +++---- blootbot/src/modules.pl | 4 +++ 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/blootbot/src/Factoids/Core.pl b/blootbot/src/Factoids/Core.pl index ec0addb..5a473d4 100644 --- a/blootbot/src/Factoids/Core.pl +++ b/blootbot/src/Factoids/Core.pl @@ -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"); diff --git a/blootbot/src/IRC/IrcHooks.pl b/blootbot/src/IRC/IrcHooks.pl index 1a77e32..9c0dcdc 100644 --- a/blootbot/src/IRC/IrcHooks.pl +++ b/blootbot/src/IRC/IrcHooks.pl @@ -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'; diff --git a/blootbot/src/Modules/News.pl b/blootbot/src/Modules/News.pl index 7bf24a5..2942f85 100644 --- a/blootbot/src/Modules/News.pl +++ b/blootbot/src/Modules/News.pl @@ -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) { diff --git a/blootbot/src/modules.pl b/blootbot/src/modules.pl index e55f015..224db3a 100644 --- a/blootbot/src/modules.pl +++ b/blootbot/src/modules.pl @@ -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(', ', @_); -- 2.39.5