QwtfDiscordBot

A Discord bot for checking the status of QuakeWorld Team Fortress servers

Dependencies

Installation

$ gem install qwtf_discord_bot

Usage

  • Create a bot on discord
  • Create a ~/.config/qwtf_discord_bot/config.yaml file containing your bots credentials and server endpoints
---
token: "dhjksahdkjhhur43hu4hu5b4b5k34j12b4kj3b4kjb4j32kb4kjb4kb3k2b"
client_id: "873298379487294398"
endpoints:
  - "sydney.fortressone.org":
    - channel_ids:
      - 832749832749873298
      - 798437748937298448
  - "sydney.fortressone.org:27501":
    - channel_ids:
      - 590204247224745986
  - "dallas.fortressone.org":
    - channel_ids:
      - 480928490328409328
emojis:
  red:
    scout: "<:scout_red:424097703127941130>"
    sniper: "<:sniper_red:424097704076115978>"
    soldier: "<:soldier_red:424097704197619712>"
    demoman: "<:demoman_red:424097687739301919>"
    medic: "<:medic_red:424097695418941451>"
    pyro: "<:pyro_red:424097704403271691>"
    hwguy: "<:hwguy_red:424097694030757889>"
    spy: "<:spy_red:424097704138899466>"
    engineer: "<:engineer_red:424097694680612864>"
  blue:
    scout: "<:scout_blue:456062063983460353>"
    sniper: "<:sniper_blue:456062061953417216>"
    soldier: "<:soldier_blue:456062062997536801>"
    demoman: "<:demoman_blue:456061938636554240>"
    medic: "<:medic_blue:456062056710537217>"
    pyro: "<:pyro_blue:456062062460928010>"
    hwguy: "<:hwguy_blue:456062063190736926>"
    spy: "<:spy_blue:456062062032846849>"
    engineer: "<:engineer_blue:456062031125020683>"
  • Use the QWTF_DISCORD_BOT_CONFIG_FILE environment variable or default to specify an alternative file
$ export QWTF_DISCORD_BOT_CONFIG_FILE="config.yaml"

Commands

There are two modules:

Server

$ qwtf-discord-bot server

This responds to discord messages:

  • !server
  • !active
  • !all

screenshot of bot responding to !server command

Watcher

$ qwtf-discord-bot watcher

This watches the game server and announces if anyone has joined the server. It polls the server once every 30 seconds and will only report a player joining if they haven't been connected for more than ten minutes.

screenshot of bot reporting player joining server

Docker

Build:

docker build --tag=discord-bot .

Push:

docker tag discord-bot fortressone/discord-bot:latest
docker push fortressone/discord-bot:latest

Run:

Assuming a ./config.yaml file exists:

Server:

docker run -it \
  --env QWTF_DISCORD_BOT_CONFIG_FILE=config.yaml \
  --mount type=bind,source="$(pwd)"/config.yaml,target=/discord-bot/config.yaml \
  discord-bot server

Watcher:

docker run -it \
  --env QWTF_DISCORD_BOT_CONFIG_FILE=config.yaml \
  --mount type=bind,source="$(pwd)"/config.yaml,target=/discord-bot/config.yaml \
  discord-bot watcher

Both:

docker-compose up

License

The gem is available as open source under the terms of the MIT License.