]> git.donarmstrong.com Git - infobot.git/commitdiff
fix on_targettoofast once and for all, hopefully.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 22 Apr 2001 14:58:05 +0000 (14:58 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 22 Apr 2001 14:58:05 +0000 (14:58 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@462 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/IrcHooks.pl

index 22df4e6a7a74f72ad43298ce7ab1610f0b9dbf53..7c6ea7881fed46d868392b46fea8007cc2816336 100644 (file)
@@ -851,9 +851,22 @@ sub on_targettoofast {
 
     ### TODO: incomplete.
     if ($why =~ /.* wait (\d+) second/) {
-       my $sleep = $1;
-       &status("targettoofast: going to sleep for $sleep...");
-       sleep $sleep;
+       my $sleep       = $1;
+       my $max         = 10;
+
+       if ($sleep > $max) {
+           &status("targettoofast: going to sleep for $max ($sleep)...");
+           $sleep = $max;
+       } else {
+           &status("targettoofast: going to sleep for $sleep");
+       }
+
+       my $delta = time() - ($cache{sleepTime} || 0);
+       if ($delta > $max+2) {
+           sleep $sleep;
+           $cache{sleepTime} = time();
+       }
+
     } else {
        if (!exists $cache{TargetTooFast}) {
            &DEBUG("on_ttf: failed: $why");