From eac6549ef0c725b86a6ec262ab870829977faeb6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Aug 2016 14:03:25 +0200 Subject: [PATCH 1/2] Some improvements --- brawlhalla.py | 3 +-- main.py | 7 +++++-- strings.py | 4 ++-- telegram.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/brawlhalla.py b/brawlhalla.py index 2bb1fb6c..6283d16c 100644 --- a/brawlhalla.py +++ b/brawlhalla.py @@ -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)) diff --git a/main.py b/main.py index ea818255..65707f28 100644 --- a/main.py +++ b/main.py @@ -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") diff --git a/strings.py b/strings.py index 66959787..77ee31e6 100644 --- a/strings.py +++ b/strings.py @@ -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_!" diff --git a/telegram.py b/telegram.py index fd2ecb33..f6d41603 100644 --- a/telegram.py +++ b/telegram.py @@ -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.") From a949eaf379435fd2a7dda84d816165b6ae0f4781 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Aug 2016 14:03:49 +0200 Subject: [PATCH 2/2] ) --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 65707f28..c6c07b1b 100644 --- a/main.py +++ b/main.py @@ -188,7 +188,7 @@ async def brawlhalla_update_mmr(timeout): if mmr != db[player]["brawlhalla"]["mmr"]: # Send a message loop.create_task(send_event(s.brawlhalla_new_mmr, player, mmr=mmr, - oldmmr=db[player]["brawlhalla"]["mmr"]) + oldmmr=db[player]["brawlhalla"]["mmr"])) # Update database db[player]["brawlhalla"]["mmr"] = mmr f = open("db.json", "w")