1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-03 16:24:20 +00:00

Show the actual medal

This commit is contained in:
Steffo 2017-01-09 08:37:09 +01:00
parent 49c1fcbbdf
commit fcdd2a9685
2 changed files with 37 additions and 12 deletions

26
main.py
View file

@ -3,12 +3,12 @@ import discord
import json
import opendota
#import overwatch
#import league
import overwatch
import league
import strings as s
import telegram
import bs4
#import brawlhalla
import brawlhalla
loop = asyncio.get_event_loop()
d_client = discord.Client()
@ -71,7 +71,9 @@ async def overwatch_status_change(timeout):
oldrank = 0
if rank != oldrank:
# Send the message
loop.create_task(send_event(eventmsg=s.overwatch_rank_change, player=player, change=rank-oldrank, rank=rank, medal=overwatch.rank_to_medal(rank)))
loop.create_task(send_event(eventmsg=s.overwatch_rank_change,
player=player, change=rank-oldrank,
rank=rank, medal=overwatch.url_to_medal(r["data"]["competitive"]["rank_img"])))
# Update database
db[player]["overwatch"]["rank"] = rank
f = open("db.json", "w")
@ -307,17 +309,17 @@ async def send_event(eventmsg: str, player: str, **kwargs):
# Send the message
loop.create_task(telegram.send_message(msg, -2141322))
#loop.create_task(overwatch_status_change(600))
#print("[Overwatch] Added level up check to the queue.")
loop.create_task(overwatch_status_change(600))
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.")
loop.create_task(league_rank_change(900))
print("[League] Added rank change check to the queue.")
#loop.create_task(league_level_up(900))
#print("[League] Added level change check to the queue.")
loop.create_task(league_level_up(900))
print("[League] Added level change check to the queue.")
#loop.create_task(brawlhalla_update_mmr(7200))
#print("[Brawlhalla] Added mmr change check to the queue.")
loop.create_task(brawlhalla_update_mmr(7200))
print("[Brawlhalla] Added mmr change check to the queue.")
loop.create_task(opendota_last_match(600))
print("[OpenDota] Added last match check to the queue.")

View file

@ -49,3 +49,26 @@ def rank_to_medal(rank):
return s.overwatch_medal_list[5]
elif int(rank) < 4000:
return s.overwatch_medal_list[6]
else:
# TODO: what
raise Exception("Mi sfugge qualcosa.")
# Convert an url to a medal
def url_to_medal(rank: str):
if rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-1.png":
return s.overwatch_medal_list[0]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-2.png":
return s.overwatch_medal_list[1]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-3.png":
return s.overwatch_medal_list[2]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-4.png":
return s.overwatch_medal_list[3]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-5.png":
return s.overwatch_medal_list[4]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-6.png":
return s.overwatch_medal_list[5]
elif rank == "https://blzgdapipro-a.akamaihd.net/game/rank-icons/season-2/rank-7.png":
return s.overwatch_medal_list[6]
else:
raise NotFoundException("The medal does not exist.")