From d36f552fc2480197dceeff3ab021d2bd37a9acd0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 13 Aug 2016 15:52:11 +0200 Subject: [PATCH] Prevent rate limits --- main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 4806e459..82f4302c 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ file.close() async def overwatch_level_up(timeout): while True: if discord_is_ready: - print("Checking for Overwatch updates.") + print("[Overwatch] Starting check...") # Update data for every player in list for player in db: if "overwatch" in db[player]: @@ -50,7 +50,7 @@ async def overwatch_level_up(timeout): f = open("db.json", "w") json.dump(db, f) f.close() - print("Check for Overwatch completed.") + print("[Overwatch] Check completed successfully.") # Wait for the timeout await asyncio.sleep(timeout) else: @@ -60,7 +60,7 @@ async def overwatch_level_up(timeout): async def league_rank_change(timeout): while True: if discord_is_ready: - print("Checking for League of Legends updates.") + print("[League] Starting check...") # Update data for every player in list for player in db: if "league" in db[player]: @@ -91,16 +91,19 @@ async def league_rank_change(timeout): f = open("db.json", "w") json.dump(db, f) f.close() - print("Check for League of Legends completed.") + # Prevent getting ratelimited by Riot + await asyncio.sleep(1) + print("[League] Check completed.") # Wait for the timeout await asyncio.sleep(timeout) else: await asyncio.sleep(1) -print("Added Overwatch to the queue.") loop.create_task(overwatch_level_up(900)) -print("Added League of Legends to the queue.") +print("[Overwatch] Added level up check to the queue.") + loop.create_task(league_rank_change(900)) +print("[League] Added rank change check to the queue.") try: loop.run_until_complete(d_client.start(token))