.FIX. .BANCHO. Add mod detection for /np when watching and playing
This commit is contained in:
parent
771b6e294b
commit
27ac94a736
|
@ -375,8 +375,12 @@ def getPPMessage(userID, just_data = False):
|
||||||
if token == None:
|
if token == None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
currentMap = token.tillerino[0]
|
||||||
|
currentMods = token.tillerino[1]
|
||||||
|
currentAcc = token.tillerino[2]
|
||||||
|
|
||||||
# Send request to LETS api
|
# 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)
|
data = json.loads(resp)
|
||||||
|
|
||||||
# Make sure status is in response data
|
# Make sure status is in response data
|
||||||
|
@ -425,21 +429,41 @@ def tillerinoNp(fro, chan, message):
|
||||||
if chan.startswith("#"):
|
if chan.startswith("#"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
playWatch = message[1] == "playing" or message[1] == "watching"
|
||||||
# Get URL from message
|
# Get URL from message
|
||||||
if message[1] == "listening":
|
if message[1] == "listening":
|
||||||
beatmapURL = str(message[3][1:])
|
beatmapURL = str(message[3][1:])
|
||||||
elif message[1] == "playing" or message[1] == "watching":
|
elif playWatch:
|
||||||
beatmapURL = str(message[2][1:])
|
beatmapURL = str(message[2][1:])
|
||||||
else:
|
else:
|
||||||
return False
|
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
|
# Get beatmap id from URL
|
||||||
beatmapID = fokabot.npRegex.search(beatmapURL).groups(0)[0]
|
beatmapID = fokabot.npRegex.search(beatmapURL).groups(0)[0]
|
||||||
|
|
||||||
# Update latest tillerino song for current token
|
# Update latest tillerino song for current token
|
||||||
token = glob.tokens.getTokenFromUsername(fro)
|
token = glob.tokens.getTokenFromUsername(fro)
|
||||||
if token != None:
|
if token != None:
|
||||||
token.tillerino = [int(beatmapID), 0, -1.0]
|
token.tillerino = [int(beatmapID), modsEnum, -1.0]
|
||||||
userID = token.userID
|
userID = token.userID
|
||||||
|
|
||||||
# Return tillerino message
|
# Return tillerino message
|
||||||
|
|
Loading…
Reference in New Issue
Block a user