From ce3c69b3394ee62666fd03c4168b01822b95cc66 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Thu, 1 Jan 2015 12:45:59 +0000 Subject: [PATCH] Some more tweaking of the flood protection code --- tipbot/ircutils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tipbot/ircutils.py b/tipbot/ircutils.py index 55471ef..2af92cd 100644 --- a/tipbot/ircutils.py +++ b/tipbot/ircutils.py @@ -23,7 +23,7 @@ irc_line_delay = 0 irc = None sslirc = None irc_password = "" -irc_min_send_delay = 0.01 # seconds +irc_min_send_delay = 0.05 # seconds irc_max_send_delay = 5 # seconds last_ping_time = time.time() @@ -48,9 +48,12 @@ def SendIRC(msg): if current_send_delay > irc_max_send_delay: current_send_delay = irc_max_send_delay else: - current_send_delay = current_send_delay / 1.5 - if current_send_delay < irc_min_send_delay: - current_send_delay = irc_min_send_delay + while dt > current_send_delay * 1.5: + dt = dt - current_send_delay + current_send_delay = current_send_delay / 1.5 + if current_send_delay < irc_min_send_delay: + current_send_delay = irc_min_send_delay + break log_IRCSEND(msg) irc_send(msg + '\r\n')