chore: update README.md
ci/woodpecker/push/govulncheck Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/tag/docker Pipeline was successful Details
ci/woodpecker/tag/deployment Pipeline was successful Details

This commit is contained in:
Dawid Wysokiński 2024-05-02 08:02:18 +02:00
parent cfbaba198a
commit 9709d956c3
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
4 changed files with 31 additions and 84 deletions

115
README.md
View File

@ -1,96 +1,43 @@
# dcbot
<div align="center">
<picture>
<img alt="TWHelp logo" src="assets/white_logo_full.png" width="50%">
</picture>
</div>
![img.png](docs/notifications.png)
<br>
A minimalist Discord bot that sends notifications of gained/lost villages.
<h1 align="center"><a href="https://www.tribalwars.net/en-dk/">Tribal Wars</a> scripts & tools to enhance your gameplay</h1>
## Getting started
<div align="center">
### Development
[![License](https://img.shields.io/badge/License-MIT-green)](#license)
[![Go Report Card](https://goreportcard.com/badge/gitea.dwysokinski.me/twhelp/dcbot)](https://goreportcard.com/report/gitea.dwysokinski.me/twhelp/dcbot)
[![CI/CD](https://woodpecker.dwysokinski.me/api/badges/11/status.svg)](https://woodpecker.dwysokinski.me/repos/11)
#### Setting up the environment
</div>
Prerequisites:
<p align="center">
<a href="https://twhelp.app/api/v2/swagger/">API</a>
·
<a href="https://gitea.dwysokinski.me/twhelp/scripts">Scripts</a>
·
<a href="https://gitea.dwysokinski.me/twhelp/dcbot">Discord Bot</a>
·
<a href="mailto:contact@twhelp.app">Report Bug</a>
·
<a href="mailto:contact@twhelp.app">Request Feature</a>
</p>
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](https://gitea.dwysokinski.me/twhelp/core)
9. [**Bot token**](https://discord.com/developers/docs/topics/oauth2#bots)
8. **direnv** (optional, but recommended)
<div align="center">
<picture>
<img alt="TWHelp logo" src="assets/notifications.png">
</picture>
</div>
```shell
# if you have direnv installed
direnv allow
## Contributing
# 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](https://github.com/ory/dockertest) will spin up a database)
- Postgres database
```shell
# 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
```shell
# create a migration
go run ./cmd/dcbot/main.go db create go migration 1
```
![img.png](docs/migration.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 |
If you would like to contribute to the software, please contact me via [email](mailto:contact@twhelp.app).
## License
Distributed under the MIT License. See ``LICENSE`` for more information.
## Contact
Dawid Wysokiński - [contact@dwysokinski.me](mailto:contact@dwysokinski.me)
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for the full license text.

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
assets/white_logo_full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB