diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-05-08 01:37:43 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-05-08 01:37:43 -0300 |
commit | 328f0e5d65fff703318917af4acf2d103d105697 (patch) | |
tree | 9b077c5f51310fe11449f7d22aaf23107891bfac /game/update.rpy | |
parent | fd0f81a4d77f672a4b7c69df8e55f40721b6dc44 (diff) | |
download | renpy-328f0e5d65fff703318917af4acf2d103d105697.tar.gz renpy-328f0e5d65fff703318917af4acf2d103d105697.tar.bz2 renpy-328f0e5d65fff703318917af4acf2d103d105697.tar.xz renpy-328f0e5d65fff703318917af4acf2d103d105697.zip |
Steam Login - If rate limited, schedule an automatic retry
Diffstat (limited to 'game/update.rpy')
-rw-r--r-- | game/update.rpy | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/game/update.rpy b/game/update.rpy index 3952921..ad72e66 100644 --- a/game/update.rpy +++ b/game/update.rpy @@ -167,7 +167,7 @@ init python: accId = steam.get_account_id() stdout("Steam login active, user %d" % accId) - # Retrieve new ticket ("token"), send it in Base64 to the API + ## Retrieve new ticket ("token"), send it in Base64 to the API steam.cancel_ticket() token = steam.get_session_ticket() auth = {"accId": accId, "token": base64.b64encode(token)} @@ -176,11 +176,24 @@ init python: ## Request the Vault for the ticket validation r = requests.post(VAULT_HOST+"/steam_auth", json=auth, timeout=15.0) + + ## Intercept rate-limiting (429) and retry once + if (r.status_code == 429): + status_update("Rate limited! Trying again 15s...", 85) + time.sleep(5.0) + status_update("Rate limited! Trying again 10s...", 85) + time.sleep(5.0) + status_update("Rate limited! Trying again 5s...", 85) + time.sleep(5.0) + status_update("Rate limited! Trying again...", 85) + r = requests.post(VAULT_HOST+"/steam_auth", json=auth, timeout=15.0) + + ## If unsucessful, give up on Steam Auth if (r.status_code != 200): steam.cancel_ticket() raise Exception("Vault returned code %d" % r.status_code) - # Receive the Vault Token + ## Receive the Vault Token stdout("Steam result: (%d) %s" % (r.status_code, ifte(config.developer, r.text, accId))) auth2 = r.json() vaultId = auth2["vaultId"] @@ -200,6 +213,9 @@ init python: vaultToken = "ERROR" ######################################### ####### TODO FIXME + # Must return and let a prompt for username & password + # (Or Email, in the case of the modern Vault) + # If vaultId is zero status_update("{color=#F00}VaultError: Not yet implemented{/color}") responsive = False return |