A minimalist Discord bot that sends notifications of gained/lost villages.
Go to file
Renovate ecbf4ba818
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/cron/govulncheck Pipeline failed Details
chore(deps): update golang docker tag to v1.21.6 (#141)
Reviewed-on: #141
Co-authored-by: Renovate <renovate@dwysokinski.me>
Co-committed-by: Renovate <renovate@dwysokinski.me>
2024-01-20 06:14:09 +00:00
.woodpecker chore: update deps (#135) 2023-10-30 08:28:14 +00:00
build/docker chore(deps): update golang docker tag to v1.21.6 (#141) 2024-01-20 06:14:09 +00:00
cmd/dcbot refactor: adapters - rename structs/files 2023-07-22 08:30:31 +02:00
docs chore: add README.md (#54) 2022-12-11 08:52:03 +00:00
internal chore: update deps (#135) 2023-10-30 08:28:14 +00:00
k8s feat: coords translation (#116) 2023-07-13 04:22:52 +00:00
migrations feat: notifications - i18n (#112) 2023-06-30 05:09:52 +00:00
.commitlintrc.yml init 2022-10-02 07:22:00 +02:00
.dockerignore chore(deps): update meltwater/drone-cache docker tag to v1.4.0 (#8) 2022-10-09 13:21:59 +00:00
.envrc init 2022-10-02 07:22:00 +02:00
.gitignore init 2022-10-02 07:22:00 +02:00
.golangci.yml chore: update deps 2023-06-08 07:40:46 +02:00
.pre-commit-config.yaml chore: update deps (#135) 2023-10-30 08:28:14 +00:00
LICENSE init 2022-10-02 07:22:00 +02:00
Makefile chore: update deps (#135) 2023-10-30 08:28:14 +00:00
README.md chore: update README.md 2022-12-20 09:48:02 +01:00
go.mod chore: update deps (#135) 2023-10-30 08:28:14 +00:00
go.sum chore: update deps (#135) 2023-10-30 08:28:14 +00:00
renovate.json refactor: refactor tools installation 2023-04-30 06:17:59 +02:00
skaffold.yml chore: update deps (#135) 2023-10-30 08:28:14 +00:00
validate_translations.sh feat: ci/cd - validate translations (#109) 2023-06-25 07:17:37 +00:00

README.md

dcbot

img.png

A minimalist Discord bot that sends notifications of gained/lost villages.

Getting started

Development

Setting up the environment

Prerequisites:

  1. Go (>= 1.19)
  2. Node.js (LTS, needed for commitlint)
  3. Kubernetes (>= 1.25.0)
    1. minikube
    2. Docker Desktop
  4. Docker CLI
  5. Skaffold
  6. pre-commit
  7. IDE/Code editor (e.g. Goland, VSCode, vim, neovim)
  8. API from core
  9. Bot token
  10. direnv (optional, but recommended)
# if you have direnv installed
direnv allow

# install git hooks and required tools
make install

# copy secret.example.yml
cp ./k8s/overlays/dev/secret.example.yml ./k8s/overlays/dev/secret.yml
# encode a bot token
echo -n 'token' | base64
# add the encoded token to secret.yml
vim ./k8s/overlays/dev/secret.yml

# run all required services
skaffold run --port-forward=true --tail=true

# stop all of them
skaffold delete

Running unit tests

At least one of the following is required to run unit tests:

  • Docker (dockertest will spin up a database)
  • Postgres database
# Docker
go test -v ./...

# Postgres database
TESTS_DB_DSN=postgres://dcbot:dcbot_pass@127.0.0.1/dcbot go test -v ./... 

Creating a new database migration

# create a migration
go run ./cmd/dcbot/main.go db create go migration 1

img.png

Configuration options

Configuration options can be specified via environment variables.

Env variable Default Description
APP_MODE development Whether to use development or production settings
DB_DSN Required. Only Postgres is supported. Example: postgres://user:password@host:5432/dbname?sslmode=disable (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
DB_MAX_OPEN_CONNECTIONS 5 Maximum number of open connections to the database (https://pkg.go.dev/database/sql#DB.SetMaxOpenConns)
DB_MAX_IDLE_CONNECTIONS 2 Maximum number of connections in the idle connection pool (https://pkg.go.dev/database/sql#DB.SetMaxIdleConns)
DB_CONNECTION_MAX_LIFETIME 3m Maximum amount of time a connection may be reused (https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime)
TWHELP_URL Required. API URL (e.g. https://tribalwarshelp.com)
TWHELP_TIMEOUT 10s Time limit for requests to TWHelp
BOT_TOKEN Required. https://discord.com/developers/docs/topics/oauth2#bots
BOT_MAX_GROUPS_PER_SERVER 10 Max number of groups per server
BOT_MAX_MONITORS_PER_GROUP 10 Max number of monitors per group

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Dawid Wysokiński - contact@dwysokinski.me