Files
uPortal2/bots/meetings_telegram_bot/README.md
T

72 lines
2.1 KiB
Markdown
Raw Normal View History

2026-10-24 20:01:40 +03:00
# 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
2026-10-24 20:36:47 +03:00
TIMEZONE=GMT+3
2026-10-24 20:01:40 +03:00
```
2026-10-24 20:36:47 +03:00
`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.
2026-10-24 20:01:40 +03:00
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.
2026-10-25 10:01:20 +03:00
- Meetings created with the "Send a Telegram notification" checkbox unchecked
are marked seen but never posted, so they stay silent in the group.
2026-10-24 20:01:40 +03:00
## 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.
2026-10-24 20:19:25 +03:00
## 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.