From bd8a063f4a4b1015fc74c4342148c381c83b9060 Mon Sep 17 00:00:00 2001 From: lenforiee Date: Sat, 25 May 2024 22:59:51 +0200 Subject: [PATCH] !mp timer command implementation (#142) * !mp timer command implementation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix assert error when match is closed and timer is still running --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- constants/chatbotCommands.py | 106 +++++++++++++++++++++++++++++++++++ objects/match.py | 6 ++ objects/matchList.py | 1 + 3 files changed, 113 insertions(+) diff --git a/constants/chatbotCommands.py b/constants/chatbotCommands.py index 082d15b5..8901c0cd 100644 --- a/constants/chatbotCommands.py +++ b/constants/chatbotCommands.py @@ -2399,6 +2399,111 @@ async def mp_link(user_token: osuToken.Token) -> str | None: return message + async def mp_timer(user_token: osuToken.Token) -> str | None: + if not user_token["match_id"]: + return None + + multiplayer_match = await match.get_match(user_token["match_id"]) + if multiplayer_match is None: + return None + + referees = await match.get_referees(multiplayer_match["match_id"]) + if user_token["user_id"] not in referees: + return None + + if len(message) < 2: + raise exceptions.invalidArgumentsException( + "Incorrect syntax: !mp timer