Skip to content

A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style ๐Ÿ˜Ž

License

Notifications You must be signed in to change notification settings

arunika0/game-server-watcher

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

game-server-watcher

Requirements: node.js (version 12.20.0 or later)

Configuration

//TODO: env vars (dotenv files supported)
//TODO: config file schema description

Starting the service

Install dependencies: npm i Build & start program: npm start

The goals of this repo

  1. create a (simple, but capable) service/bot to monitor game servers
    1. get gamedig & steam api server info (eg.: server name, map, players, etc.)
    2. relay real time server information to various channels via APIs (eg.: discord, telegram, slack etc.)
  2. should be able to host on a free service (target atm. is cloudno.de (nodejs 12.20.1))
  3. graciously add more features based on community feedback

Get support on discord or on github.
More detailed customization options and additional features will be added as requested.

SCREENSHOTS

Possible features and configuration options to add in the future

  • optional player list
    • with configurable fields. eg.: time,name,ping,score
    • configurable field & order to sort by
    • max length for player names & nr of players
  • custom embed fields for discord
  • configurable timezone for graph x-axis
  • refresh on reaction
  • watched players (notify when a watched player enters/leaves the server)
  • detect server restart, notify when player number crosses a threshold
  • bot commands (reinit message, cleanup, start/stop, configure)
  • more integrations: slack, ms teams, twillio (email, sms)
  • web ui to manage & configure the servers and bots
  • put custom information in the channel name (online status indicator, number of players, map)

Self host on cloudno.de

You can fork (copy) this repo on github, and automatically deploy your configuration or other changes as a cloud service.

Part 1: create and setup cloudno.de repo

  1. register account
  2. create app: https://cloudno.de/myapps?new //TODO: create app, make sure to set the latest node.js version and leave server.js as entry point;
  3. provision app
  4. copy https git URL from app
  5. go to profile copy your token
  6. add username and as authentication to the URL like https://username:[email protected]/git/username/xyz; save it for later (github)
  7. go to application --> manage --> environment
  8. set DATA_PATH=/mnt/ in cloud app env
    //go to https://cloudno.de/account --> API tokens // on github: goto settings --> secrets --> actions and setup CLOUDNODE_REPO_URL secret with the full URL

Part 2 (optional): create and invite discord bot and get token

//TODO: create discord bot;

  1. create app
  2. create bot
  3. under the bots name you should seee a token or an option to reset token
  4. check message content intent
  5. oauth2 --> url generator --> check bot as scopes; create bot invite link with permissions: view channels, send messages, message history, embed links, add reaction (85056),
  6. invite bot to servers(guilds)
  7. create bot auth token, copy it
  8. setup DISCORD_BOT_TOKEN in cloud app env
  9. //CONFIG: find and copy then setup channel ids in config

Part 3 (optional): create telegram bot and get token

//TODO: get token from botfather and setup as TELEGRAM_BOT_TOKEN in cloud app env; get chat id from getidsbot and setup chat ids in config

Part 4 (optional): create steam web api key

//TODO: request a web api key and setup as STEAM_WEB_API_KEY in cloud app env; set appId fields in config

Part 5: create and setup github repo

//TODO: fork this repo

  1. hit fork button
  2. repo settings page --> actions --> general: allow all actions (if no confirmation comes up, disable then re-enable all actions)

Part 6: create cloud branch, configure and deploy the service

  1. switch to the cloud branch of your fork; (git checkout -b cloud)
  2. create a new config file (and setup GSW_CONFIG in cloud app env to point to it) or edit config/default.config.json and save it
  3. commit and push your changes (git add . && git commit -m :shipit: && git push origin cloud)

You can also just use the github web editor to make changes to the default config file, just make sure to switch to the cloud branch to have it automatically deployed.

Commiting your changes and pushing your commits to github will trigger github actions to push your files to cloudno.de and restart the app

Manage

A few web endpoints are available to clear out service data.
Make sure to configure a proper SECRET env var to enable these!

Servers /flush/servers/SECRET

Removes all stored game server data:

  • population history configured by PLAYERS_HISTORY_HOURS

Telegram /flush/telegram/SECRET

The bot has no cleanup functionality, left over messages must be removed manually.
If the original message created by the bot gets deleted, you need to flush the bot data to reinitialize the message.

Discord /flush/discord/SECRET

The bot has no cleanup functionality, left over messages must be removed manually.
If the original message created by the bot gets deleted, you might need to flush the bot data to reinitialize the message.

Development

Running locally

npm i
npm run dev

Nodejs v12 dependency limitations

About

A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style ๐Ÿ˜Ž

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.1%
  • Other 1.9%