mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
fics
This commit is contained in:
parent
34a575aa27
commit
25a248be86
2 changed files with 3 additions and 23 deletions
2
main.py
2
main.py
|
@ -83,6 +83,8 @@ async def overwatch_status_change(timeout):
|
||||||
rank=rank, medal=overwatch.url_to_medal(r["data"]["competitive"]["rank_img"])))
|
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
|
||||||
|
else:
|
||||||
|
db[player]["overwatch"]["rank"] = 0
|
||||||
save_db()
|
save_db()
|
||||||
finally:
|
finally:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
22
opendota.py
22
opendota.py
|
@ -1,22 +0,0 @@
|
||||||
import asyncio
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
|
|
||||||
async def get_latest_match(steamidtre: str):
|
|
||||||
steamidtre = steamidtre[1:-1].split(":")[2]
|
|
||||||
print("[OpenDota] Getting latest match for: {steamid}".format(steamid=steamidtre))
|
|
||||||
r = await loop.run_in_executor(None, requests.get, 'https://api.opendota.com/api/players/{steamidtre}/matches?limit=1'.format(steamidtre=steamidtre))
|
|
||||||
if r.status_code == 200:
|
|
||||||
pj = r.json()
|
|
||||||
return pj[0]
|
|
||||||
else:
|
|
||||||
raise Exception("OpenDota request error")
|
|
||||||
|
|
||||||
def get_hero_name(heroid: int):
|
|
||||||
j = open("herolist.json", "r")
|
|
||||||
herolist = json.loads(j.read())
|
|
||||||
for hero in herolist:
|
|
||||||
if hero["id"] == heroid:
|
|
||||||
return hero["localized_name"]
|
|
||||||
return None
|
|
Loading…
Reference in a new issue