Skip to content

Lightweight & clean dockerized Aiogram templates for creating Telegram bots

License

Notifications You must be signed in to change notification settings

avrtt/tg-bot-boilerplates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

An expanding collection of easily adaptable Aiogram templates for building Telegram bots.

Features

  • Easily extensible and maintainable code
  • Simple and clean architecture
  • RedisStorage caching for retaining message history
  • Ready-to-use Alembic migration system
  • Modern DB engine

Template 1

  • Design UIs easily with Aiogram Dialog

Template 2

  • Localization with Project Fluent
  • Enviroment configuration with Poetry

Dependencies


Setup & usage

Clone the repository and navigate to the template-1 folder:

git clone git@github.com:avrtt/tg-bot-boilerplates.git
cd tg-bot-boilerplates/template-1

Create an .env file with the following contents and fill the lines (<...>):

API_TOKEN=<...>
POSTGRES_USER=bot_user
POSTGRES_PASSWORD=<...>
POSTGRES_DB=bot_db
DB_HOST=db
DB_PORT=5432
DB_NAME=bot_db
DB_USER=bot_user
DB_PASS=<...>

Build:

docker-compose up --build

In the bot container, run:

alembic revision --autogenerate -m "init"

For using migrations:

alembic upgrade head

For shutting down the bot:

docker-compose down -v

Navigate to the template-2 folder instead. Rename docker-compose.example.yml to docker-compose.yml and .env.dist to .env. Configure .env in the same way.

Build:

make app-build

Start:

make app-run

Setup environment:

poetry install

Update DB tables structure. Make the migration script:

make migration message=MIGRATION_DESCRIPTION

Run migrations:

make migrate

Translation

For updating translations, parse the new localization keys:

make i18n locale=TRANSLATION_LOCALE

Write new translations in .ftl (translations/TRANSLATION_LOCALE) and restart the bot.


License

This templates are licensed under the MIT License - see the LICENSE file for details.