def get_group_bnsite_comment(event: Event) -> str: """Returns any comment the bnsite has put on group events (e.g. BN removal reasons), if any, otherwise None.""" if not event.group: raise ValueError("Event lacks a group.") # Only comments removals of BNs. if event.type != types.REMOVE or event.group.id not in [32, 28]: return None json = bnsite_api.request_last_eval(event.user.id) if not json or eval_likely_outdated(eval_json=json): return None kind = json["kind"] if kind == "resignation": comment = "Resigned" elif kind == "currentBn": consensus = json["consensus"] if "consensus" in json else None if consensus is None: comment = None # Movement within the Beatmap Nominators is self-explanatory given both the added+removed events. elif consensus == "fullBn": comment = None elif consensus == "probationBn": comment = None elif consensus == "removeFromBn": comment = "Kicked" else: raise ValueError(f"Unrecognized evaluation consensus \"{consensus}\".") else: raise ValueError(f"Unrecognized evaluation kind \"{kind}\".") return comment
def get_group_bnsite_mode(event: Event) -> str: """Returns the mode of the bn according to the bnsite (e.g. "taiko"), if any, otherwise None.""" if not event.group: raise ValueError("Event lacks a group.") # Can only get mode of groups the bnsite keeps track of. if event.group.id not in [7, 32, 28]: return None json = bnsite_api.request_last_eval(event.user.id) if not json or eval_likely_outdated(eval_json=json): return None return json["mode"]
def test_request_last_eval_resign(): # https://osu.ppy.sh/users/1263669 json = api.request_last_eval(user_id=8140944) assert json assert json["kind"] == "resignation" assert from_string(json["updatedAt"])
def test_request_last_eval_missing(): json = api.request_last_eval(user_id=4) assert not json
def test_request_last_eval_kick(): # https://osu.ppy.sh/users/5875419 json = api.request_last_eval(user_id=5875419) assert json assert json["consensus"] == "removeFromBn" assert from_string(json["updatedAt"])