From 94f0972c5b89670fd71bfb5882e5e77fa39bfda5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 9 Jan 2017 08:39:13 +0100 Subject: [PATCH] Display a plus if the overwatch rank change is positive --- main.py | 2 +- overwatch.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 8e89ccf5..d9bff1bc 100644 --- a/main.py +++ b/main.py @@ -72,7 +72,7 @@ async def overwatch_status_change(timeout): if rank != oldrank: # Send the message loop.create_task(send_event(eventmsg=s.overwatch_rank_change, - player=player, change=rank-oldrank, + player=player, change=overwatch.format_rankchange(rank-oldrank), rank=rank, medal=overwatch.url_to_medal(r["data"]["competitive"]["rank_img"]))) # Update database db[player]["overwatch"]["rank"] = rank diff --git a/overwatch.py b/overwatch.py index 6519ab3f..b0d20d2b 100644 --- a/overwatch.py +++ b/overwatch.py @@ -71,4 +71,10 @@ def url_to_medal(rank: str): 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.") \ No newline at end of file + raise NotFoundException("The medal does not exist.") + +def format_rankchange(rankchange: int): + if rankchange < 0: + return "+" + str(rankchange) + else: + return str(rankchange) \ No newline at end of file