1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
This commit is contained in:
Steffo 2016-08-29 12:33:22 +02:00
commit f4e5f7e321
4 changed files with 9 additions and 7 deletions

View file

@ -1,11 +1,10 @@
import asyncio import asyncio
import requests import requests
import bs4
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
# Get ladder page for a player # Get ladder page for a player
async def get_leaderboard_for(name: str): 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 # Get leaderboards page for that name
r = await loop.run_in_executor(None, requests.get, r = await loop.run_in_executor(None, requests.get,
"http://www.brawlhalla.com/rankings/1v1/eu/?p={name}".format(name=name)) "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, loop.create_task(send_event(eventmsg=s.league_rank_up,
player=player, player=player,
tier=s.league_tier_list[tier_number], 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 # Update database
db[player]["league"]["tier"] = tier_number db[player]["league"]["tier"] = tier_number
db[player]["league"]["division"] = roman_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 # Compare the mmr with the value saved in the database
if mmr != db[player]["brawlhalla"]["mmr"]: if mmr != db[player]["brawlhalla"]["mmr"]:
# Send a message # 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 # Update database
db[player]["brawlhalla"]["mmr"] = mmr db[player]["brawlhalla"]["mmr"] = mmr
f = open("db.json", "w") f = open("db.json", "w")

View file

@ -4,7 +4,7 @@
overwatch_level_up = "{player} è salito al livello **{level}** su _Overwatch_!" overwatch_level_up = "{player} è salito al livello **{level}** su _Overwatch_!"
# League of Legends: Rank up! # 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 of Legends: Tier list
league_tier_list = ["Bronzo", league_tier_list = ["Bronzo",
@ -19,4 +19,4 @@ league_tier_list = ["Bronzo",
league_level_up = "{player} è salito al livello **{level}** su _League of Legends_!" league_level_up = "{player} è salito al livello **{level}** su _League of Legends_!"
# Brawlhalla: new MMR # 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: if r.status_code == 200:
return return
else: else:
raise Exception("Qualcosa è andato storto su Telegram. Ops.") raise Exception("Something went wrong in the Telegram request.")