mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
wow finalmente il codice di overwatch è quasi leggibile
This commit is contained in:
parent
2ca9675f31
commit
6e85449799
2 changed files with 19 additions and 21 deletions
38
main.py
38
main.py
|
@ -46,34 +46,32 @@ async def overwatch_status_change(timeout):
|
|||
print("[Overwatch] Request returned an unhandled exception.")
|
||||
else:
|
||||
# Check for levelups
|
||||
if "level" not in db[player]["overwatch"] \
|
||||
or r["data"]["level"] > db[player]["overwatch"]["level"]:
|
||||
level = r["data"]["level"]
|
||||
try:
|
||||
oldlevel = db[player]["overwatch"]["level"]
|
||||
except KeyError:
|
||||
oldlevel = 0
|
||||
if level > oldlevel:
|
||||
# Send the message
|
||||
loop.create_task(send_event(eventmsg=s.overwatch_level_up,
|
||||
player=player,
|
||||
level=r["data"]["level"]))
|
||||
loop.create_task(send_event(eventmsg=s.overwatch_level_up, player=player, level=level))
|
||||
# Update database
|
||||
db[player]["overwatch"]["level"] = r["data"]["level"]
|
||||
db[player]["overwatch"]["level"] = level
|
||||
f = open("db.json", "w")
|
||||
json.dump(db, f)
|
||||
f.close()
|
||||
# Check for rank changes
|
||||
if r["data"]["competitive"]["rank"] is not None:
|
||||
if "rank" not in db[player]["overwatch"] \
|
||||
or int(r["data"]["competitive"]["rank"]) != db[player]["overwatch"]["rank"]:
|
||||
if "rank" not in db[player]["overwatch"]:
|
||||
db[player]["overwatch"]["rank"] = 0
|
||||
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,
|
||||
oldmedal=overwatch.rank_to_medal(
|
||||
db[player]["overwatch"]["rank"]),
|
||||
oldrank=db[player]["overwatch"]["rank"],
|
||||
rank=int(r["data"]["competitive"]["rank"]),
|
||||
medal=overwatch.rank_to_medal(
|
||||
int(r["data"]["competitive"]["rank"]))))
|
||||
loop.create_task(send_event(eventmsg=s.overwatch_rank_change, player=player, change=oldrank-rank, rank=rank, medal=overwatch.rank_to_medal(rank)))
|
||||
# Update database
|
||||
db[player]["overwatch"]["rank"] = int(r["data"]["competitive"]["rank"])
|
||||
db[player]["overwatch"]["rank"] = rank
|
||||
f = open("db.json", "w")
|
||||
json.dump(db, f)
|
||||
f.close()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
overwatch_level_up = "{player} è salito al livello **{level}** su _Overwatch_!"
|
||||
|
||||
# Overwatch: Rank change!
|
||||
overwatch_rank_change = "{player} è passato da {oldmedal} {oldrank} a **{medal} {rank}** su _Overwatch_!"
|
||||
overwatch_rank_change = "{player} è ora **{medal} {rank}** ({change}) su _Overwatch_!"
|
||||
|
||||
# Overwatch: Medal list
|
||||
overwatch_medal_list = ["Nulla",
|
||||
|
|
Loading…
Reference in a new issue