From 1e9c3ea0f817b4c5a2ece013eef104130187f6d7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 20 Apr 2017 22:37:47 +0200 Subject: [PATCH] =?UTF-8?q?lol=20ma=20era=20cos=C3=AC=20semplice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 869c5e29..0d4655f7 100644 --- a/main.py +++ b/main.py @@ -68,22 +68,23 @@ async def overwatch_status_change(timeout): # Update database db[player]["overwatch"]["level"] = level # Check for rank changes - # rank = r["data"]["competitive"]["rank"] - # if rank is not None: - # rank = int(rank) - # try: - # oldrank = int(db[player]["overwatch"]["rank"]) - # except KeyError: - # oldrank = 0 - # if rank != oldrank: - # # Send the message - # loop.create_task(send_event(eventmsg=s.overwatch_rank_change, - # player=player, change=overwatch.format_rankchange(rank-oldrank), - # rank=rank, medal=overwatch.url_to_medal(r["data"]["competitive"]["rank_img"]))) - # # Update database - # db[player]["overwatch"]["rank"] = rank - # else: - db[player]["overwatch"]["rank"] = None + rank = r["data"]["competitive"]["rank"] + if rank is not None: + rank = int(rank) + try: + oldrank = int(db[player]["overwatch"]["rank"]) + except KeyError: + oldrank = 0 + if rank != oldrank: + # Send the message + loop.create_task(send_event(eventmsg=s.overwatch_rank_change, + player=player, change=overwatch.format_rankchange(rank-oldrank), + rank=rank, medal=overwatch.url_to_medal(r["data"]["competitive"]["rank_img"]))) + # Update database + db[player]["overwatch"]["season"] = 4 + db[player]["overwatch"]["rank"] = rank + else: + db[player]["overwatch"]["rank"] = None save_db() finally: await asyncio.sleep(1)