From 23081601b3268308ff69b73115a7aea4f54ba9e0 Mon Sep 17 00:00:00 2001 From: JensForstmann <19289807+JensForstmann@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:45:54 +0100 Subject: [PATCH] Add version command --- backend/src/commands.ts | 2 ++ backend/src/match.ts | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/commands.ts b/backend/src/commands.ts index 7584909..e89ff33 100644 --- a/backend/src/commands.ts +++ b/backend/src/commands.ts @@ -15,6 +15,7 @@ const Commands = [ 'SWITCH', 'TEAM', 'RESTART', + 'VERSION', '*', ] as const; export type TCommand = typeof Commands[number]; @@ -38,6 +39,7 @@ commandMapping.set('switch', 'SWITCH'); commandMapping.set('swap', 'SWITCH'); commandMapping.set('team', 'TEAM'); commandMapping.set('restart', 'RESTART'); +commandMapping.set('version', 'VERSION'); export const getInternalCommandByUserCommand = (userCommand: string) => { return commandMapping.get(userCommand); diff --git a/backend/src/match.ts b/backend/src/match.ts index 20993c4..0dbfd6f 100644 --- a/backend/src/match.ts +++ b/backend/src/match.ts @@ -1,6 +1,6 @@ import { ValidateError } from '@tsoa/runtime'; import { generate as shortUuid } from 'short-uuid'; -import { TMT_LOG_ADDRESS } from '.'; +import { TMT_LOG_ADDRESS, VERSION } from '.'; import { escapeRconSayString, escapeRconString, @@ -652,9 +652,14 @@ const onConsoleSay = async (match: Match, message: string) => { export const registerCommandHandlers = () => { commands.registerHandler('TEAM', onTeamCommand); + commands.registerHandler('VERSION', onVersionCommand); commands.registerHandler('*', onEveryCommand); }; +const onVersionCommand: commands.CommandHandler = async (e) => { + await say(e.match, `TMT version: ${VERSION ?? 'unknown'}`); +}; + const onEveryCommand: commands.CommandHandler = async (e) => { if (!e.player.team) { return;