From 27ac94a736e902a0ed1ca337294732ddc22a113c Mon Sep 17 00:00:00 2001 From: Isaac Drew Date: Sun, 28 Aug 2016 21:20:41 +0800 Subject: [PATCH] .FIX. .BANCHO. Add mod detection for /np when watching and playing --- constants/fokabotCommands.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index 1390c37..e38b27e 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -375,8 +375,12 @@ def getPPMessage(userID, just_data = False): if token == None: return False + currentMap = token.tillerino[0] + currentMods = token.tillerino[1] + currentAcc = token.tillerino[2] + # Send request to LETS api - resp = requests.get("http://127.0.0.1:5002/api/v1/pp?b={}&m={}&a={}".format(token.tillerino[0], token.tillerino[1], token.tillerino[2]), timeout=10).text + resp = requests.get("http://127.0.0.1:5002/api/v1/pp?b={}&m={}&a={}".format(currentMap, currentMods, currentAcc), timeout=10).text data = json.loads(resp) # Make sure status is in response data @@ -425,21 +429,41 @@ def tillerinoNp(fro, chan, message): if chan.startswith("#"): return False + playWatch = message[1] == "playing" or message[1] == "watching" # Get URL from message if message[1] == "listening": beatmapURL = str(message[3][1:]) - elif message[1] == "playing" or message[1] == "watching": + elif playWatch: beatmapURL = str(message[2][1:]) else: return False + modsEnum = 0 + mapping = { + "-Easy": mods.Easy, + "-NoFail": mods.NoFail, + "+Hidden": mods.Hidden, + "+HardRock": mods.HardRock, + "+Nightcore": mods.Nightcore, + "+DoubleTime": mods.DoubleTime, + "-HalfTime": mods.HalfTime, + "+Flashlight": mods.Flashlight, + "-SpunOut": mods.SpunOut + } + + if playWatch: + for part in message: + part = part.replace("\x01", "") + if part in mapping.keys(): + modsEnum += mapping[part] + # Get beatmap id from URL beatmapID = fokabot.npRegex.search(beatmapURL).groups(0)[0] # Update latest tillerino song for current token token = glob.tokens.getTokenFromUsername(fro) if token != None: - token.tillerino = [int(beatmapID), 0, -1.0] + token.tillerino = [int(beatmapID), modsEnum, -1.0] userID = token.userID # Return tillerino message