Ensure uv is installed, then create a new Telegram bot project with:
uvx --with copier-templates-extensions copier copy --trust -r HEAD gh:TimNekk/copier-telegram-bot ~/path/to/your/project
Built with Copier, this template lets you toggle features during setup - choose what you need and generate files instantly! Ready for Docker π³ and Coolify βοΈ deployment.
-
Docker Compose
π³ Launch bot + services with one command -
Python 3.9β3.13
π Choose your Python version easily -
uv
π Fast dependency management powered by Rust -
Poetry
π¦ Manage dependencies safely with virtual environments -
pip
π Classic Python package installer
-
Aiogram
β‘ Modern async bot framework with state management -
Aiogram Dialog
πΌοΈ Create menus and interactive interfaces -
Redis
β€οΈ Keep bot data safe between restarts
-
PostgreSQL
π Powerful database for complex projects -
SQLAlchemy
π οΈ Work with databases using Python code -
Alembic
β³ Track and apply database changes easily
-
Dependency Injection
π Share tools/data across bot handlers -
Throttling
π Stop spam with automatic speed limits -
Database Sessions
β»οΈ Auto-manage database connections -
Loguru
π Simple logging with colors and fun
-
Pydantic Settings
β Safe config management with type checking -
Dynaconf
βοΈ Configs for dev/test/prod environments -
Ruff
πͺΆ Super-fast code linting and cleanup -
Justfile
πͺ Short commands for complex tasks -
Cache Decorator
β‘ Speed up functions with Redis caching
The fully-featured generated project can be found in the example/ directory.
Below is the folder structure of the generated project:
.
βββ bot # Main directory for the bot's source code
β βββ cache # Contains caching-related modules
β β βββ redis.py # Module for Redis-based caching functionality
β β βββ serialization.py # Handles serialization and deserialization for cached data
β β
β βββ core # Core components of the bot
β β βββ loader.py # Initializes and loads core components of the bot
β β βββ settings.py # Configuration and settings for the bot
β β
β βββ database # Database-related modules and models
β β βββ models # Directory for database model definitions
β β β βββ base.py # Base class for database models
β β βββ database.py # Database connection
β β
β βββ dialogs # Dialog flow and interaction logic
β β βββ example # Example implementation of dialogs
β β βββ dialogs.py # Defines dialogs
β β βββ getters.py # Retrieves data required for dialogs
β β βββ handlers.py # Handles user interactions within dialogs
β β
β βββ filters/ # Custom filters for handling specific bot commands or messages
β β
β βββ handlers # General handlers for bot events
β β βββ start.py # Handler for the /start command
β β
β βββ keyboards # Defines inline and reply keyboards for user interaction
β β βββ inline # Inline keyboards
β β βββ default_commands.py # Defualt commands setup
β β
β βββ middleware # Middleware modules to extend bot behavior
β β βββ database.py # Middleware to manage database interactions during eventxs
β β βββ dependency.py # Dependency injection middleware for shared resources
β β βββ logger.py # Middleware to log events
β β βββ throttling.py # Middleware to handle rate-limiting of requests
β β
β βββ services/ # Auxiliary services with business logic
β β
β βββ __main__.py # Entry point to run the bot application
β βββ states.py # FMS states
β
βββ migrations # Database migration files (managed by Alembic)
β βββ versions/ # Directory containing individual migration scripts
β βββ env.py # Alembic environment configuration file
β βββ script.py.mako # Template for generating new migration scripts
β
βββ .dockerignore # Specifies files and directories to ignore in Docker builds
βββ .gitignore # Specifies files and directories to ignore in Git version control
βββ .python-version # Python version specification file for version managers like pyenv
βββ .env # Environment variable settings file
βββ .template.env # Template file for environment variables
βββ alembic.ini # Alembic configuration file for database migrations
βββ compose.yaml # Docker Compose configuration file for multi-container setups
βββ Dockerfile # Instructions to build a Docker image for the application
βββ entrypoint.sh # Script executed as the container's entry point
βββ justfile # Task runner configuration file (for `just` command automation)
βββ pyproject.toml # Python project metadata and dependencies configuration (PEP-518)
βββ README.md # Documentation readme file describing the project
βββ uv.lock # Lock file generated by a dependency manager
Before using the Copier Telegram Bot template, ensure you have the following installed:
- Copier: Refer to the installation guide.
- Copier Templates Extensions: Refer to the repository for installation instructions.
Once these prerequisites are installed, you're ready to use the template!
copier copy --trust -r HEAD gh:TimNekk/copier-telegram-bot ~/path/to/your/project
Copier will ask you a lot of questions. Answer them to properly generate the template.
Help shape the future! Planned improvements:
-
Bot Internationalization
π Support multiple languages for global audiences -
Prompts Internationalization
π Translate copier prompts -
Dependabot
π€ Add dependencies auto-update to generated project for security and freshness -
Testing
β Add testing framework -
Flake8
/wemake
π§Ή Alternative strict linting for code quality fans
Got ideas? Star β the repo or open an issue to collaborate! π
- For a small change, just send a PR.
- For bigger changes open an issue for discussion before sending a PR.
- PR should have:
- Test case
- Documentation
- Example (If it makes sense)
Distributed under the Apache License 2.0. See LICENSE
for more information.