1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44: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 json
import opendota import opendota
#import overwatch import overwatch
#import league import league
import strings as s import strings as s
import telegram import telegram
import bs4 import bs4
#import brawlhalla import brawlhalla
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
d_client = discord.Client() d_client = discord.Client()
@ -71,7 +71,9 @@ async def overwatch_status_change(timeout):
oldrank = 0 oldrank = 0
if rank != oldrank: if rank != oldrank:
# Send the message # 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 # Update database
db[player]["overwatch"]["rank"] = rank db[player]["overwatch"]["rank"] = rank
f = open("db.json", "w") f = open("db.json", "w")
@ -307,17 +309,17 @@ async def send_event(eventmsg: str, player: str, **kwargs):
# Send the message # Send the message
loop.create_task(telegram.send_message(msg, -2141322)) loop.create_task(telegram.send_message(msg, -2141322))
#loop.create_task(overwatch_status_change(600)) loop.create_task(overwatch_status_change(600))
#print("[Overwatch] Added level up check to the queue.") print("[Overwatch] Added level up check to the queue.")
#loop.create_task(league_rank_change(900)) loop.create_task(league_rank_change(900))
#print("[League] Added rank change check to the queue.") print("[League] Added rank change check to the queue.")
#loop.create_task(league_level_up(900)) loop.create_task(league_level_up(900))
#print("[League] Added level change check to the queue.") print("[League] Added level change check to the queue.")
#loop.create_task(brawlhalla_update_mmr(7200)) loop.create_task(brawlhalla_update_mmr(7200))
#print("[Brawlhalla] Added mmr change check to the queue.") print("[Brawlhalla] Added mmr change check to the queue.")
loop.create_task(opendota_last_match(600)) loop.create_task(opendota_last_match(600))
print("[OpenDota] Added last match check to the queue.") 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] return s.overwatch_medal_list[5]
elif int(rank) < 4000: elif int(rank) < 4000:
return s.overwatch_medal_list[6] 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.")