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

Some improvements

This commit is contained in:
Steffo 2016-08-19 14:03:25 +02:00
parent ac6644a49e
commit eac6549ef0
4 changed files with 9 additions and 7 deletions

View file

@ -1,11 +1,10 @@
import asyncio
import requests
import bs4
loop = asyncio.get_event_loop()
# Get ladder page for a player
async def get_leaderboard_for(name: str):
print("[Brawlhalla] Getting leaderboards page for {name}".format(name=name))
print("[Brawlhalla] Getting leaderboards page for: {name}".format(name=name))
# Get leaderboards page for that name
r = await loop.run_in_executor(None, requests.get,
"http://www.brawlhalla.com/rankings/1v1/eu/?p={name}".format(name=name))

View file

@ -94,7 +94,9 @@ async def league_rank_change(timeout):
loop.create_task(send_event(eventmsg=s.league_rank_up,
player=player,
tier=s.league_tier_list[tier_number],
division=r["entries"][0]["division"]))
division=r["entries"][0]["division"],
oldtier=db[player]["league"]["tier"],
olddivision=db[player]["league"]["division"]))
# Update database
db[player]["league"]["tier"] = tier_number
db[player]["league"]["division"] = roman_number
@ -185,7 +187,8 @@ async def brawlhalla_update_mmr(timeout):
# Compare the mmr with the value saved in the database
if mmr != db[player]["brawlhalla"]["mmr"]:
# Send a message
loop.create_task(send_event(s.brawlhalla_new_mmr, player, mmr=mmr))
loop.create_task(send_event(s.brawlhalla_new_mmr, player, mmr=mmr,
oldmmr=db[player]["brawlhalla"]["mmr"])
# Update database
db[player]["brawlhalla"]["mmr"] = mmr
f = open("db.json", "w")

View file

@ -4,7 +4,7 @@
overwatch_level_up = "{player} è salito al livello **{level}** su _Overwatch_!"
# League of Legends: Rank up!
league_rank_up = "{player} è salito alla divisione **{tier} {division}** su _League of Legends_!"
league_rank_up = "{player} è passato da {oldtier} {olddivision} a **{tier} {division}** su _League of Legends_!"
# League of Legends: Tier list
league_tier_list = ["Bronzo",
@ -19,4 +19,4 @@ league_tier_list = ["Bronzo",
league_level_up = "{player} è salito al livello **{level}** su _League of Legends_!"
# Brawlhalla: new MMR
brawlhalla_new_mmr = "{player} ora ha **{mmr}** MMR su _Brawlhalla_!"
brawlhalla_new_mmr = "{player} è passato da {oldmmr} MMR a **{mmr}** MMR su _Brawlhalla_!"

View file

@ -22,4 +22,4 @@ async def send_message(msg: str, to: int):
if r.status_code == 200:
return
else:
raise Exception("Qualcosa è andato storto su Telegram. Ops.")
raise Exception("Something went wrong in the Telegram request.")