1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 16:56:16 +00:00

FLOOD_WAIT-Protection now adds a few minutes of waiting time to give the API time to relax. Also increased the delay between file downloads to 1.5 seconds.

This commit is contained in:
Fabian Schlenz 2016-07-06 07:52:20 +02:00
parent 30618b4e3e
commit 799bad9755
2 changed files with 14 additions and 9 deletions

View File

@ -36,7 +36,7 @@ class Config {
public static final int FILE_DOWNLOAD_BLOCK_SIZE = 10*1024*1024;
public static int DELAY_AFTER_GET_MESSAGES = 200;
public static int DELAY_AFTER_GET_FILE = 750;
public static int DELAY_AFTER_GET_FILE = 1000;
public static final String SECRET_GMAPS = "AIzaSyBEtUDhCQKEH6i2Mn1GAiQ9M_tLN0vxHIs";
}

View File

@ -172,15 +172,20 @@ class DownloadManager {
completed = false;
Config.DELAY_AFTER_GET_FILE = 1500;
int delay = Integer.parseInt(e.getTag().substring(16));
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.");
System.out.println("So we now have to wait a bit. Telegram asked us to wait for " + delay + " seconds, which");
System.out.println("is about " + ((delay / 60) + 1) + " minutes.");
System.out.println("So I'm going to do that now. If you don't want to wait, you can quit by pressing");
System.out.println("Ctrl+C. You can restart me at any time and I will just continue to download your");
System.out.println("messages and media. But be advised that just restarting me is not going to change");
System.out.println("the fact that Telegram won't talk to me until then.");
try { Thread.sleep((delay + 60) * 1000); } catch(InterruptedException e2) {}
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" +
"\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) {}
System.out.println("");
} else {
throw e;