A minimal, container-ready python-telegram-bot
(v21, async) starter. Bring your token, write your handlers in bot.py.
-
Create a bot and copy its token from @BotFather.
-
Put the token in a
.envfile next todocker-compose.yml:TELEGRAM_TOKEN=123456:your-token
-
Build & run:
docker compose up --build
The token is read at runtime only (never baked into the image), and .env is git-ignored.
In Telegram, open your bot and send /hello — it replies Hello <your first name>.
Add your handlers in bot.py (async, python-telegram-bot v21 API):
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
TELEGRAM_TOKEN=… python bot.py- Lint/format:
ruff—ruff check&ruff format --check. - Dockerfile lint:
hadolint. - Both run in CI (
.github/workflows/ci.yml). - Pinned base image (
python:3.12-alpine) and dependency (python-telegram-bot[all]~=21.0).