Skip to content

Bot template for telegram, using Aiogram 3.x, SQLAlchemy + Alembic

License

Notifications You must be signed in to change notification settings

NotBupyc/aiogram-bot-template

Repository files navigation

Aiogram3 Bot Template


System dependencies

Configure


Install dependencies

On host

make install

For developing (include ruff, mypy, pre-commit)

make install-dev

Configure environment variables

  1. Copy file .env.example and rename it to .env
  2. Open it and configure it
  3. If you used Redis find REDIS_USE and set True
# Redis settings
REDIS_USE=True

Installing modules for SQLAlchemy to work with databases

For PostgreSQL

poetry add asyncpg 

for MySQL

poetry add asyncmy

Default database - PostgreSQL. You can change this in .env DB_USED

Migrations

For migrations using Alembic

Create revision
make migration message=message

upgrade database

make migrate

Starting

make start

Features

  • Flexible choice between PostgreSQL and MySQL
  • In bot/middlewares/ there are already several middlewares in the folder(ThrottlingMiddleware)
  • In bot/filters there are already several middlewares in the folder(IsAdmin)
  • DailyRotatingFileHandler - logs are written to a file with the current date from 00:00 to 23:59 and stored in the logs folder
  • TelegramHandler - logs are sent to the telegram chat

Used technologies: