📖 This README is also available in 🇷🇺 Russian
create-tg-bot is a Python CLI tool and boilerplate generator for creating Telegram bots using a modular and extensible architecture. It scaffolds the basic project structure, including handlers, keyboards, models, and services, and includes a manage.py interface for generating new components.
- Modular project layout
- Jinja2 templating for generating project files
- Built-in generator for models, keyboards, and command handlers
manage.pyCLI powered by Click- Templates for CRUD, keyboards, and message formatting
- Support for future integration of async ORM, logging, i18n
pip install create-tg-bot- Install the package:
pip install create-tg-bot- Generate a new bot project:
create-tg-bot my_bot
cd my_bot- Use CLI to generate components:
python manage.py gen-model user
python manage.py gen-keyboard main
python manage.py gen-command startproject/
├── .env # Environment variables for local development
├── alembic.ini # Alembic configuration file for DB migrations
├── config.py # Global configuration settings (token, DB URL, etc.)
├── main.py # Entry point to start the bot
├── models/ # SQLAlchemy models for database schema
├── services/ # Business logic and service layer
├── crud/ # Functions for Create, Read, Update, Delete operations
├── migrations/ # Alembic migration scripts for database versioning
├── templates/ # Jinja2 templates for code generation
├── requirements.txt # Python dependencies
├── commands/ # Message handlers for bot commands (e.g. /start, /help)
├── keyboards/ # Inline and reply keyboard definitions
├── button_handlers/ # Callback query handlers for inline buttons
├── texts/ # Static texts and formatting functions
├── utils/ # General-purpose helper functions
├── manage.py # CLI entry point to generate code via Click commands
└── .github/workflows/ # CI/CD pipeline definitions (e.g., GitHub Actions)
- Uses
setuptools_scmfor automatic versioning - Templates live in
create_tg_bot/templates - CLI interface powered by
Click
This project is licensed under the MIT License.