1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

lol ma era così semplice

This commit is contained in:
Steffo 2017-04-20 22:37:47 +02:00
parent 998593b334
commit 1e9c3ea0f8

33
main.py
View file

@ -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)