Skip to content

aiogram-cmds

Command management library for aiogram v3 - Manage Telegram bot commands with i18n support, user profiles, and dynamic scopes.

๐Ÿš€ Quick Start

Get started with aiogram-cmds in under 5 minutes:

from aiogram import Bot, Dispatcher
from aiogram_cmds.auto_setup import setup_commands_auto

async def on_startup():
    # Automatically set up commands with sensible defaults
    command_manager = await setup_commands_auto(bot)
    # Commands are ready to use!

โœจ Key Features

๐ŸŽฏ Three Usage Modes

  • Auto-Setup: Zero configuration, works out of the box
  • Simple Mode: Settings-based configuration with policies
  • Advanced Mode: Full control with profiles, scopes, and custom resolvers

๐ŸŒ i18n Integration

  • Built-in support for aiogram i18n
  • Automatic fallback handling
  • Multi-language command descriptions

๐Ÿ‘ฅ User Profiles

  • Dynamic command sets based on user status
  • Guest, registered, admin, and custom profiles
  • Runtime profile switching

๐ŸŽ›๏ธ Multiple Scopes

  • All Telegram command scopes supported
  • Private chats, groups, admins, specific users
  • Hierarchical scope management

๐Ÿ”ง Production Ready

  • Type-safe with full type hints
  • Comprehensive testing suite
  • CI/CD pipeline
  • Extensive documentation

๐Ÿ“– Documentation

Getting Started

Tutorials

API Reference

Architecture & Performance

๐ŸŽฏ Common Use Cases

E-commerce Bot

profiles = {
    "visitor": ProfileDef(include=["start", "catalog", "help"]),
    "customer": ProfileDef(include=["start", "catalog", "cart", "orders", "help"]),
    "vip": ProfileDef(include=["start", "catalog", "cart", "orders", "vip_offers", "help"]),
}

Admin Bot

scopes = [
    ScopeDef(scope="all_private_chats", profile="user"),
    ScopeDef(scope="chat_member", chat_id=12345, user_id=67890, profile="admin"),
]

Multi-Language Bot

config = CmdsConfig(
    languages=["en", "ru", "es", "fr"],
    commands={
        "start": CommandDef(i18n_key="commands.start"),
        "help": CommandDef(i18n_key="commands.help"),
    }
)

๐Ÿ—๏ธ Architecture Overview

aiogram-cmds provides a layered architecture that scales from simple to complex:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Auto-Setup    โ”‚    โ”‚   Simple Mode    โ”‚    โ”‚  Advanced Mode  โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ”‚ setup_commands_ โ”‚    โ”‚ CmdsSettings +   โ”‚    โ”‚ CmdsConfig +    โ”‚
โ”‚ auto()          โ”‚    โ”‚ CommandPolicy    โ”‚    โ”‚ ProfileResolver โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚ CommandScopeMgr  โ”‚
                    โ”‚                  โ”‚
                    โ”‚ โ€ข setup_all()    โ”‚
                    โ”‚ โ€ข update_user()  โ”‚
                    โ”‚ โ€ข clear_user()   โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚   Telegram API   โ”‚
                    โ”‚                  โ”‚
                    โ”‚ โ€ข set_commands   โ”‚
                    โ”‚ โ€ข delete_commandsโ”‚
                    โ”‚ โ€ข menu_button    โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Installation

# Basic installation
pip install aiogram-cmds

# With Redis support (for multi-worker deployments)
pip install aiogram-cmds[redis]

๐Ÿค Community

  • ๐Ÿ’ฌ Discussions - Questions, ideas, and community chat
  • ๐Ÿ› Issues - Bug reports and feature requests
  • ๐Ÿ“– Documentation - Complete guides and API reference

๐Ÿ“Š Project Status

  • โœ… Core Features: Command management, i18n, profiles, scopes
  • โœ… Documentation: Comprehensive guides and API reference
  • โœ… Testing: Unit, integration, and performance tests
  • โœ… CI/CD: Automated testing and deployment
  • ๐Ÿšง Examples: Working bot examples (in progress)
  • ๐Ÿ”ฎ Future: Rate limiting, caching, advanced analytics

Ready to get started? Check out our Quickstart Guide or browse the Examples!