This repository contains a template for Telegram bots built with aiogram 3.20.0post0, providing a structured foundation for your bot development.
- Create a
.envfile in the root directory - Add your bot token:
BOT_TOKEN=your_telegram_bot_token_here
The template uses a dynamic initialization system that converts JSON template files into Python dataclasses for easier usage in your code.
On each code execution:
- JSON template files from the
templates/directory are processed - Corresponding Python dataclasses are generated in the
templates/enums/directory - These classes become immediately available for import
Important
The templates/enums/ directory is generated automatically on first execution and is not included in the source code.
Template File Format:
{
"attribute_name": "attribute_value",
"nested_attribute": {
"inner_attribute_name": "inner_attribute_value"
}
}To create a custom template:
- Create a
your_template_name.jsonfile in thetemplates/directory - Register your template in
templates/__init__.py
Your template will be converted to a dataclass in templates/enums/your_template_name.py with class name YourTemplateName.
Note
Nested dictionaries are automatically converted to separate dataclasses in templates/enums/mod_your_template_name/attribute_name.py and accessible as attributes of the parent class.
Tip
Templates are processed before other code executes, so you can safely import your template classes at the top of your files.
You can find extended functional in branches