From 4d7e46caa1b65444515711caf0145d01e254c16a Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 15 Sep 2016 06:37:42 +0200 Subject: [PATCH] Removed the extra waiting time when obeying FLOOD_WAIT exceptions. --- src/main/java/de/fabianonline/telegram_backup/Utils.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/Utils.java b/src/main/java/de/fabianonline/telegram_backup/Utils.java index a161d4a..daa2fb2 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Utils.java +++ b/src/main/java/de/fabianonline/telegram_backup/Utils.java @@ -49,20 +49,17 @@ public class Utils { if (e==null || e.getCode()!=420) return; int delay = e.getTagInteger(); - int minutes = (delay/60)+1; - int wait = (minutes / 5) * 5 + 5; System.out.println(""); System.out.println( "Telegram complained about us (okay, me) making too many requests in too short time by\n" + "sending us \"" + e.getTag() + "\" as an error. So we now have to wait a bit. Telegram\n" + - "asked us to wait for " + delay + " seconds, which is about " + minutes + " minutes.\n" + - "I'm adding a few minutes to let the API recover, so we are going to wait for " + wait + " mins.\n" + + "asked us to wait for " + delay + " seconds.\n" + "\n" + "So I'm going to do just that for now. If you don't want to wait, you can quit by pressing\n" + "Ctrl+C. You can restart me at any time and I will just continue to download your\n" + "messages and media. But be advised that just restarting me is not going to change\n" + "the fact that Telegram won't talk to me until then."); - try { Thread.sleep(wait * 60 * 1000); } catch(InterruptedException e2) {} + try { Thread.sleep((delay + 1) * 1000); } catch(InterruptedException e2) {} System.out.println(""); }