JensForstmann / tmt2

TMT - Tournament Match Tracker: Supervise/Manage Counter-Strike 2 matches with ease!
MIT License
24 stars 6 forks source link
counter-strike counter-strike-2 cs2 cs2-bot cs2-tournament csgo csgo-bot csgo-server-administration csgo-tournament

TMT2 - Tournament Match Tracker 2

Docker Pulls Docker Image Size (tag)

TMT is a tool that tracks/watches/observes a Counter-Strike 2 match.

It will keep track of matches and can interact with 3rd party applications like tournament systems, websites or others via a REST API and webhooks to send real time notifications.

FEATURES

Example screenshot: Banning a map from the map pool: Ban a map (screenshot)


Table of Contents:

Getting Started

TMT2 is available on docker hub: https://hub.docker.com/r/jensforstmann/tmt2

Run it with:

docker run --name tmt2 -d -p 8080:8080 jensforstmann/tmt2

Data will be written within the container to /app/backend/storage. To keep the files with different containers you can either specify a docker volume or a path on the local system:

# docker volume
docker run --name tmt2 -d -p 8080:8080 -v dockerVolumeName:/app/backend/storage jensforstmann/tmt2

# local host directory
docker run --name tmt2 -d -p 8080:8080 -v /home/tmt2/storage:/app/backend/storage jensforstmann/tmt2

The matches which are neither finished nor stopped will be loaded on application start.

Create you first Match

After running the container you can open the web frontend: http://localhost:8080 (or at whatever ip/server your docker container runs on.)

Example screenshot: Create a new match from the web frontend (both dark and light mode available): Create a new match (screenshot)

Even without an admin token you can create and manage matches (but only your own ones). If you want to know your admin token (a random one is generated at startup) either take a look at the access_tokens.json file or take a look at the first lines of the log output (docker logs tmt2).

Ingame Chat Commands

While TMT watches a match the player ingame can use chat commands to communicate with TMT:

Configuration

Just use these environment variables:

# http port that tmt listens on
TMT_PORT=8080

# the address the game server must send the logs to (from the pov of the game server)
# if not set a tmtLogAddress must be for every match
TMT_LOG_ADDRESS=http://127.0.0.1:8080

# where tmt will store match data in
TMT_STORAGE_FOLDER=storage

# ingame prefix to every chat message sent by this application
TMT_SAY_PREFIX="[TMT] "

API

See backend/swagger.json. You might want to copy its content and paste it into https://editor.swagger.io/.

See also the examples folder.

Security / Authentication

There are two types of authentication:

Global access tokens have full permissions. Match specific ones can only access its own match.

Both are used in client requests in the Authorization header with a "Bearer "-prefix:

...
Authorization: Bearer 2Mgog6ATqAs495NtUQUsph
...

global access tokens

Global access tokens are persisted in the storage folder in the file access_tokens.json.

Example:

{
    "2Mgog6ATqAs495NtUQUsph": { // that's the token
        "comment": "first auto generated token" // optional comment, might be used in logging
    },

    // multiple tokens are also possible
    "knRRkV41yLBUw1eVwRD9VF": {
        "comment": "Jens"
    },
    "vZQjPZBXRAK6yhCwoboxWk": {
        "comment": "tournament system"
    }
}

If the file does not exist at startup a new one with a single auto generated global access token will be created.

match specific access tokens

Every match will have a tmtSecret property. This can be used in the same way as a global access token.


Development

After starting the dev processes you can reach the backend & frontend at:

Docker

Docker is recommended as it's easy to use and doesn't require any other software to be installed (if docker is already set up).

Note for windows user: It's recommended to have docker installed directly within WSL (not using Windows Docker from WSL) or to run a Linux VM.

Init the dev environment:

./dev-container-init.sh

Start a docker container with port forwarding and hot reloading:

./dev-container-start.sh

NodeJS

If you don't want to use docker or want to use NodeJS directly, you can do the following to setup a dev environment:

Install dependencies:

npm install
cd backend
npm install
cd ../frontend
npm install

Run backend with hot reloading:

cd backend
npm run dev

Run frontend with hot reloading:

cd frontend
npm run dev

This project is a complete rewrite of the former TMT.