A Telegram bot using python-telegram-bot. Included:
- PostgreSQL Database & SQLAlchemy models
- Migrations with Alembic
- Pre-commit hooks with ruff
Set up poetry:
poetry install --no-root && poetry shell
Get Telegram Bot Token from @BotFather.
Create env.sh
file from env_example.sh
.
Execute source env.sh
to set environment variables.
Run database:
docker-compose up -d db
Run migrations:
poetry run alembic upgrade head
Run bot:
poetry run python3 -m bot
Run migrations:
poetry run alembic revision --autogenerate -m "Migration: 0## Title"
poetry run alembic upgrade head
__main__.py
: Entry point of the applicationmodels.py
: SQLAlchemy modelssettings.py
: Configuration and environment variableshandlers/
: Folder for bot command handlers