From a43b81ee91965b4beba77ca5cba6f87a1ed92057 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 15 Jul 2016 22:22:58 +0200 Subject: [PATCH] Rewritten FLOOD_WAIT detection code. --- .../java/de/fabianonline/telegram_backup/DownloadManager.java | 2 +- src/main/java/de/fabianonline/telegram_backup/Utils.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java index b0684cf..6d591da 100644 --- a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java +++ b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java @@ -70,7 +70,7 @@ public class DownloadManager { try { _downloadMessages(limit); } catch (RpcErrorException e) { - if (e.getTag().startsWith("420: FLOOD_WAIT_")) { + if (e.getCode()==420) { // FLOOD_WAIT completed = false; Utils.obeyFloodWaitException(e); } else { diff --git a/src/main/java/de/fabianonline/telegram_backup/Utils.java b/src/main/java/de/fabianonline/telegram_backup/Utils.java index 3811537..4de408d 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Utils.java +++ b/src/main/java/de/fabianonline/telegram_backup/Utils.java @@ -34,9 +34,9 @@ public class Utils { } static void obeyFloodWaitException(RpcErrorException e) throws RpcErrorException { - if (e==null || ! e.getTag().startsWith("420: FLOOD_WAIT_")) return; + if (e==null || e.getCode()!=420) return; - int delay = Integer.parseInt(e.getTag().substring(16)); + int delay = e.getTagInteger(); int minutes = (delay/60)+1; int wait = (minutes / 5) * 5 + 5; System.out.println("");