From b5806bdfbf10061af64e37237943c85483a7aae6 Mon Sep 17 00:00:00 2001 From: russelg Date: Wed, 15 Jun 2016 01:51:54 +0800 Subject: [PATCH] .ADD. .BANCHO. Add stars to !last and use mods in star calculation for tillerino --- constants/fokabotCommands.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index 4906d45..a18d43b 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -321,7 +321,7 @@ def systemStatus(fro, chan, message): return msg -def getPPMessage(userID): +def getPPMessage(userID, just_data = False): try: # Get user token token = glob.tokens.getTokenFromUserID(userID) @@ -343,6 +343,9 @@ def getPPMessage(userID): else: raise exceptions.apiException + if just_data: + return data + # Return response in chat # Song name and mods msg = "{song}{plus}{mods} ".format(song=data["song_name"], plus="+" if token.tillerino[1] > 0 else "", mods=generalFunctions.readableMods(token.tillerino[1])) @@ -482,7 +485,7 @@ def tillerinoAcc(fro, chan, message): def tillerinoLast(fro, chan, message): try: data = glob.db.fetch("""SELECT beatmaps.song_name as sn, scores.*, - beatmaps.beatmap_id as bid + beatmaps.beatmap_id as bid, beatmaps.difficulty FROM scores LEFT JOIN beatmaps ON beatmaps.beatmap_md5=scores.beatmap_md5 LEFT JOIN users ON users.id = scores.userid @@ -499,9 +502,23 @@ def tillerinoLast(fro, chan, message): msg += " on " if chan == "FokaBot" else " | {0} on ".format(fro) msg += "[http://osu.ppy.sh/b/{1} {0}]".format(data["sn"], data["bid"]) + stars = data["difficulty"] if data["mods"]: msg += ' +' + generalFunctions.readableMods(data["mods"]) + + token = glob.tokens.getTokenFromUsername(fro) + if token == None: + return False + userID = token.userID + token.tillerino[0] = data["bid"] + token.tillerino[1] = data["mods"] + token.tillerino[2] = data["accuracy"] + oppaiData = getPPMessage(userID, just_data=True) + if "stars" in oppaiData: + stars = oppaiData["stars"] + msg += " ({0:.2f}%, {1})".format(data["accuracy"], rank.upper()) + msg += " | {0:.2f} stars".format(stars) return msg except Exception as a: