From a810304eee0d0546f6d2a329e81bdd3de626f49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Thu, 11 Nov 2021 15:28:54 +0100 Subject: [PATCH] Add function to move clients manually That can be used when the last player checked in from the website. Maybe this can be automated in the future with polling or webhooks. --- app.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app.ts b/app.ts index 69e9cbb..a94c8f2 100644 --- a/app.ts +++ b/app.ts @@ -32,6 +32,7 @@ let admin_commands = new Map([ ["!cancelMatch", "Cancel the ongoing match"], ["!finish ", "Finish the ongoing match with WINNER (TEAM1, TEAM2)"], ["!set ", "Set ATTRIBUTE (elo) to VALUE"], + ["!move ", "Move clients in DIRECTION (optional, back)"], ]); teamspeak.on("ready", async () => { @@ -78,6 +79,9 @@ teamspeak.on("textmessage", (ev) => { case "!help": help(clid, teamspeakID); break; + case "!move": + move_clients_wrapper(clid, teamspeakID, argv[1]); + break; } }); @@ -369,6 +373,25 @@ async function start_match() { } } +// move clients manually, in case match was started from website +async function move_clients_wrapper( + clid: string, + teamspeakID: string, + direction: string +) { + const admin = await is_admin(clid, teamspeakID); + if (!admin) { + message(clid, "Only an admin can do that."); + return; + } + + if (direction === "back") { + move_clients(true); + } else { + move_clients(false); + } +} + async function move_clients(back: boolean = false) { const query = gql` query { -- 2.44.0