91 lines
2.4 KiB
Markdown
91 lines
2.4 KiB
Markdown
# mic-bot
|
|
|
|
Telegram chat and inline bot for our community https://t.me/mental_illness_center_bot
|
|
|
|
## Features
|
|
|
|
### Captcha
|
|
When new user starts the bot it sends him a captcha. After passing the captcha user can get the chat invite
|
|
|
|
### Safebooru image search
|
|
To search images via safebooru just type in your message prompt<br>
|
|
`@mental_illness_center_bot sfbr <tags>`<br>
|
|
and it will find images for you.
|
|
|
|
## TODO:
|
|
- Safebooru images lazy loading
|
|
- Minecraft server intergration
|
|
- Referal system
|
|
- Safebooru ChatGPT text to tags
|
|
|
|
## Config
|
|
|
|
### File config
|
|
|
|
Before running **MIC** create file `./config.json` that contains
|
|
```json
|
|
{
|
|
// BOT_TOKEN env variable has more priority
|
|
// that the config value
|
|
"bot_token": "<your_token>"
|
|
// to run in Docker set the value to
|
|
// "/run/secrets/db_password"
|
|
// If wasn't set -- POSTGRES_PASSWORD env
|
|
// variable will be used instead
|
|
"db_password_file": "~/.secrets/mic",
|
|
// other optional db config parameters
|
|
|
|
// Defaults can be seen/changed inside the config.ts file
|
|
"db_user": string,
|
|
"db_name": string,
|
|
"db_port": number,
|
|
// if you are running under docker -- set host to postgres
|
|
"db_host": string,
|
|
"db_tls": boolean,
|
|
}
|
|
```
|
|
|
|
### Environment variables
|
|
|
|
- `POSTGRESS_PASSWORD`
|
|
DB Password. If Config file property `db_password_file` has been set -- it will be used instead
|
|
- `BOT_TOKEN`
|
|
Telegram bot token. Has bigger priority than the config property
|
|
- `MIC_CONFIG_PATH`
|
|
Specifies the path to a MIC config file. `./config.json` by default
|
|
- `MIC_APPLY_MIGRATIONS`
|
|
(y/N) // Set it to "y" before running the MIC for the first time to apply DB migrations. Gets reseted to "n" automatically so migrations are applied once
|
|
- `MIC_DROP_DB`
|
|
(y/N) // **I WILL RAPE U IF U USE IT ON A PROD DB. ONLY FOR DEVELOPMENT!!!** Gets reseted to "n" automatically for security reasons
|
|
|
|
More advanced parameters can be configured at `config.ts`.
|
|
|
|
## Running
|
|
> [!WARNING]
|
|
> **Read the Config section before running. App won't start without a valid configuration!**
|
|
### Docker
|
|
|
|
```sh
|
|
# Create directories required by the app
|
|
mkdir .secrets postgres_data
|
|
# Set the DB password
|
|
nvim .secrets/db_password.txt
|
|
# Classical docker commands
|
|
docker compose build
|
|
docker compose up
|
|
```
|
|
|
|
### Host
|
|
Before running the bot on host -- setup
|
|
|
|
```sh
|
|
mkdir bin
|
|
# With compilation
|
|
deno compile -o ./bin/mic ./main.ts
|
|
./bin/mic
|
|
# Just run it
|
|
deno run ./main.ts
|
|
# Dev run with autorestart
|
|
deno run ./main.ts
|
|
```
|