71 lines
2.0 KiB
Markdown
71 lines
2.0 KiB
Markdown
# Meetings - Telegram bot
|
|
|
|
A small standalone Python bot. It polls the API every 15 minutes and posts newly
|
|
created meetings to a Telegram group. It is not part of Docker; you run it by
|
|
hand.
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
pip install -r ../requirements.txt
|
|
cp .env.example .env
|
|
# edit .env
|
|
```
|
|
|
|
`.env`:
|
|
|
|
```env
|
|
API_BASE_URL=http://localhost:8088
|
|
API_LOGIN=bot-user
|
|
API_PASSWORD=change-me
|
|
TELEGRAM_BOT_TOKEN=123456:ABC-DEF-your-token
|
|
TELEGRAM_CHAT_ID=@my-group
|
|
TIMEZONE=GMT+3
|
|
```
|
|
|
|
`TIMEZONE` sets the zone for the times in posts. Use an IANA name
|
|
(`Europe/Moscow`) or a GMT offset (`GMT+3`, `UTC+05:30`). Leave it empty to use
|
|
the machine's local time.
|
|
|
|
Get the bot token from [@BotFather](https://t.me/BotFather). For a public group
|
|
use `@group_name`; for a private group use the numeric chat id (negative).
|
|
|
|
## Run
|
|
|
|
From the project root:
|
|
|
|
```bash
|
|
python bots/run_bot.py # start the loop
|
|
python bots/run_bot.py --once # one cycle, then exit
|
|
python bots/run_bot.py --dry-run # log only, post nothing
|
|
python bots/run_bot.py --check # validate config, then exit
|
|
```
|
|
|
|
Stop with `Ctrl-C`.
|
|
|
|
## Notes
|
|
|
|
- On the first run the bot remembers existing meetings **without posting them**,
|
|
so it does not spam the group. Only meetings created afterwards are posted.
|
|
- The join link in each post opens the web app's room page, and only appears
|
|
when the meeting has a room.
|
|
|
|
## Optional: SOCKS5 proxy
|
|
|
|
```env
|
|
SOCKS5_PROXY=socks5://user:password@127.0.0.1:1080
|
|
```
|
|
|
|
Routes both API and Telegram traffic through the proxy. Leave empty to connect
|
|
directly.
|
|
|
|
## Troubleshooting
|
|
|
|
- `CSRF Token Validation Failed`: delete `state.json` (stale cookies) and run
|
|
again. The bot seeds the csrf cookie itself and sends cookies even when the
|
|
server marks them `Secure`, so plain-HTTP setups work.
|
|
- `401 Unauthorized`: check `API_LOGIN` / `API_PASSWORD`.
|
|
- `chat not found`: check `TELEGRAM_CHAT_ID` and that the bot is in the group.
|
|
- Nothing posted: the first run intentionally stays silent. Create a meeting
|
|
after the bot starts.
|