Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

create-tg-bot

PyPI version License: MIT CI/CD

📖 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.


🔧 Features

  • Modular project layout
  • Jinja2 templating for generating project files
  • Built-in generator for models, keyboards, and command handlers
  • manage.py CLI powered by Click
  • Templates for CRUD, keyboards, and message formatting
  • Support for future integration of async ORM, logging, i18n

📦 Installation

pip install create-tg-bot

🚀 Quick Start

  1. Install the package:
pip install create-tg-bot
  1. Generate a new bot project:
create-tg-bot my_bot
cd my_bot
  1. Use CLI to generate components:
python manage.py gen-model user
python manage.py gen-keyboard main
python manage.py gen-command start

📁 Project Structure

project/
├── .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)


🧪 Development Notes

  • Uses setuptools_scm for automatic versioning
  • Templates live in create_tg_bot/templates
  • CLI interface powered by Click

📄 License

This project is licensed under the MIT License.


👤 Author

Emil Astanov

About

Open Source CLI Boilerplate for Telegram Bots (Python) A modular, production-ready boilerplate for building Telegram bots using Python with a command-line interface. Designed for rapid development, clean code organization, and easy extension. Ideal for open-source contributors looking for a solid starting point

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages