def mpSettings(): _match = glob.matches.matches[getMatchIDFromChannel(chan)] msg = "PLAYERS IN THIS MATCH:\n" empty = None for slot in _match.slots: if slot.user is None: continue readableStatuses = { slotStatuses.READY: "ready", slotStatuses.NOT_READY: "not ready", slotStatuses.NO_MAP: "no map", slotStatuses.PLAYING: "playing", } if slot.status not in readableStatuses: readableStatus = "???" else: readableStatus = readableStatuses[slot.status] empty = False msg += "* [{team}] <{status}> ~ {username}{mods}\n".format( team="red" if slot.team == matchTeams.RED else "blue" if slot.team == matchTeams.BLUE else "!! no team !!", status=readableStatus, username=glob.tokens.tokens[slot.user].username, mods=" (+ {})".format(generalUtils.readableMods(slot.mods)) if slot.mods > 0 else "") if empty: msg += "\nNobody." return msg
def mpSettings(): _match = glob.matches.matches[getMatchIDFromChannel(chan)] single = False if len(message) < 2 else message[1].strip().lower() == "single" msg = "PLAYERS IN THIS MATCH " if not single: msg += "(use !mp settings single for a single-line version):" msg += "\n" else: msg += ": " empty = True for slot in _match.slots: if slot.user is None: continue readableStatuses = { slotStatuses.READY: "ready", slotStatuses.NOT_READY: "not ready", slotStatuses.NO_MAP: "no map", slotStatuses.PLAYING: "playing", } if slot.status not in readableStatuses: readableStatus = "???" else: readableStatus = readableStatuses[slot.status] empty = False msg += "* [{team}] <{status}> ~ {username}{mods}{nl}".format( team="red" if slot.team == matchTeams.RED else "blue" if slot.team == matchTeams.BLUE else "!! no team !!", status=readableStatus, username=glob.tokens.tokens[slot.user].username, mods=" (+ {})".format(generalUtils.readableMods(slot.mods)) if slot.mods > 0 else "", nl=" | " if single else "\n" ) if empty: msg += "Nobody.\n" msg = msg.rstrip(" | " if single else "\n") return msg
def recommend(fro, chan, message): user_id = userUtils.getID(fro) user = userUtils.getUserStats(user_id, 0) params = { 'pp': user['pp'], 'token': glob.conf.config["kotrik"]["pprapi"] } mega_pp_recommendation = requests.get("https://api.kotrik.ru/api/recommendMap", params=params) result = None try: result = json.loads(mega_pp_recommendation.text) except: return "I can't recommend you, because api is broken(" mods = generalUtils.readableMods(result['m']) if mods == "": mods = "nomod" formatResult = "[http://osu.ppy.sh/b/{bid} {art} - {name} [{diff}]] Stars: {stars} | BPM: {bpm} | Length: {length} | PP: {pps} {mods}".format( bid=result['b'], art=result['art'], name=result['t'], diff=result['v'], stars=result['d'], bpm=result['bpm'], length=kotrikhelper.secondsToFormatted(result['l']), pps=result['pp99'], mods=f"+{mods}" ) return formatResult
def mp_settings(): userID = userUtils.getID(fro) if not can_user_touch_lobby(get_match_id_from_channel(chan), userID): return False _match = glob.matches.matches[get_match_id_from_channel(chan)] msg = "PLAYERS IN THIS MATCH:\n" empty = True for slot in _match.slots: if slot.user is None: continue readable_statuses = { slotStatuses.READY: "ready", slotStatuses.NOT_READY: "not ready", slotStatuses.NO_MAP: "no map", slotStatuses.PLAYING: "playing", } if slot.status not in readable_statuses: readable_status = "???" else: readable_status = readable_statuses[slot.status] empty = False msg += "* [{team}] <{status}> ~ {username}{mods}\n".format( team="red" if slot.team == matchTeams.RED else "blue" if slot.team == matchTeams.BLUE else "!! no team !!", status=readable_status, username=glob.tokens.tokens[slot.user].username, mods=" (+ {})".format(generalUtils.readableMods(slot.mods)) if slot.mods > 0 else "") if empty: msg += "Nobody.\n" return msg
def settings(response, token, sender, channel, message): _match = getCurrentMatch(channel) single = False if len(message) < 2 else message[0].strip().lower( ) == "single" msg = "PLAYERS IN THIS MATCH " if not single: # msg += "(use !mp settings single for a single-line version):" msg += "\n" else: msg += ": " empty = True for slot in _match.slots: if slot.user is None: continue readableStatuses = { slotStatuses.READY: "ready", slotStatuses.NOT_READY: "not ready", slotStatuses.NO_MAP: "no map", slotStatuses.PLAYING: "playing", } if slot.status not in readableStatuses: readableStatus = "???" else: readableStatus = readableStatuses[slot.status] empty = False msg += "* {team}{username}{mods} <{status}>{nl}".format( team="[R] " if slot.team == matchTeams.RED else "[B] " if slot.team == matchTeams.BLUE else "", status=readableStatus, username=glob.tokens.tokens[slot.user].username, mods=" (+ {})".format(generalUtils.readableMods(slot.mods)) if slot.mods > 0 else "", nl=" | " if single else "\n") if empty: msg += "Nobody.\n" msg = msg.rstrip(" | " if single else "\n") response.setContent(token, msg) response.listen_in = [token.token]
def tillerinoLast(fro, chan, message): try: # Run the command in PM only if chan.startswith("#"): return False data = glob.db.fetch( """SELECT beatmaps.song_name as sn, scores.*, beatmaps.beatmap_id as bid, beatmaps.difficulty_std, beatmaps.difficulty_taiko, beatmaps.difficulty_ctb, beatmaps.difficulty_mania, beatmaps.max_combo as fc FROM scores LEFT JOIN beatmaps ON beatmaps.beatmap_md5=scores.beatmap_md5 LEFT JOIN users ON users.id = scores.userid WHERE users.username = %s ORDER BY scores.time DESC LIMIT 1""", [fro]) if data is None: return False diffString = "difficulty_{}".format( gameModes.getGameModeForDB(data["play_mode"])) rank = generalUtils.getRank(data["play_mode"], data["mods"], data["accuracy"], data["300_count"], data["100_count"], data["50_count"], data["misses_count"]) ifPlayer = "{0} | ".format(fro) if chan != "FokaBot" else "" ifFc = " (FC)" if data["max_combo"] == data[ "fc"] else " {0}x/{1}x".format(data["max_combo"], data["fc"]) beatmapLink = "[http://osu.ppy.sh/b/{1} {0}]".format( data["sn"], data["bid"]) hasPP = data["play_mode"] == gameModes.STD or data[ "play_mode"] == gameModes.MANIA msg = ifPlayer msg += beatmapLink if data["play_mode"] != gameModes.STD: msg += " <{0}>".format( gameModes.getGameModeForPrinting(data["play_mode"])) if data["mods"]: msg += ' +' + generalUtils.readableMods(data["mods"]) if not hasPP: msg += " | {0:,}".format(data["score"]) msg += ifFc msg += " | {0:.2f}%, {1}".format(data["accuracy"], rank.upper()) msg += " {{ {0} / {1} / {2} / {3} }}".format( data["300_count"], data["100_count"], data["50_count"], data["misses_count"]) msg += " | {0:.2f} stars".format(data[diffString]) return msg msg += " ({0:.2f}%, {1})".format(data["accuracy"], rank.upper()) msg += ifFc msg += " | {0:.2f}pp".format(data["pp"]) stars = data[diffString] if data["mods"]: token = glob.tokens.getTokenFromUsername(fro) if token is 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} stars".format(stars) return msg except Exception as a: log.error(a) return False
def getPPMessage(userID, just_data=False): try: # Get user token token = glob.tokens.getTokenFromUserID(userID) if token is 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={}".format( currentMap, currentMods), timeout=10).text data = json.loads(resp) # Make sure status is in response data if "status" not in data: raise exceptions.apiException # Make sure status is 200 if data["status"] != 200: if "message" in data: return "Error in LETS API call ({}).".format(data["message"]) 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 currentMods > 0 else "", mods=generalUtils.readableMods(currentMods)) # PP values if currentAcc == -1: msg += "95%: {pp95}pp | 98%: {pp98}pp | 99% {pp99}pp | 100%: {pp100}pp".format( pp100=data["pp"][0], pp99=data["pp"][1], pp98=data["pp"][2], pp95=data["pp"][3]) else: msg += "{acc:.2f}%: {pp}pp".format(acc=token.tillerino[2], pp=data["pp"][0]) originalAR = data["ar"] # calc new AR if HR/EZ is on if (currentMods & mods.EASY) > 0: data["ar"] = max(0, data["ar"] / 2) if (currentMods & mods.HARDROCK) > 0: data["ar"] = min(10, data["ar"] * 1.4) arstr = " ({})".format(originalAR) if originalAR != data["ar"] else "" # Beatmap info msg += " | {bpm} BPM | AR {ar}{arstr} | {stars:.2f} stars".format( bpm=data["bpm"], stars=data["stars"], ar=data["ar"], arstr=arstr) # Return final message return msg except requests.exceptions.RequestException: # RequestException return "API Timeout. Please try again in a few seconds." except exceptions.apiException: # API error return "Unknown error in LETS API call."