~xenrox/10man-ts3

a810304eee0d0546f6d2a329e81bdd3de626f49f — Thorben Günther 2 years ago 4e22405
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.
1 files changed, 23 insertions(+), 0 deletions(-)

M app.ts
M app.ts => app.ts +23 -0
@@ 32,6 32,7 @@ let admin_commands = new Map([
    ["!cancelMatch", "Cancel the ongoing match"],
    ["!finish <WINNER>", "Finish the ongoing match with WINNER (TEAM1, TEAM2)"],
    ["!set <STEAMID64> <ATTRIBUTE> <VALUE>", "Set ATTRIBUTE (elo) to VALUE"],
    ["!move <DIRECTION>", "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 {