# 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
`@mental_illness_center_bot safebooru `
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
{
// 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",
// BOT_TOKEN env variable has more priority
// that the config value
"bot_token": ""
}
```
### 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
```