Skip to main content

Lightweight wrapper over aiogram 3.x

Project description

re_aiogram

re_aiogram is a lightweight wrapper over aiogram 3.x that keeps the familiar aiogram API while simplifying bot development and adding extra features.

The goal of the project is to stay fully compatible with aiogram, but provide a cleaner and more convenient developer experience.


Install

pip install re_aiogram
import re_aiogram

Features

  • familiar aiogram-style API
  • simplified bot startup without explicit dispatcher
  • router auto-loading
  • built-in MediaGroup support
  • aiogram-compatible imports

Quick Start

from re_aiogram import Bot, Message
from re_aiogram.filters import Command

API_TOKEN = "YOUR_API_TOKEN"

bot = Bot(token=API_TOKEN)


@bot.message(Command("start"))
async def cmd_start(message: Message):
    await message.answer(
        "Hi! I am a Telegram bot powered by re_aiogram!"
    )


bot.run(logging_enabled=True)

MediaGroup Handler

Built-in support for Telegram media groups.

from re_aiogram import Bot, Message
from re_aiogram.filters import F
from re_aiogram.types import MediaGroup

bot = Bot(token="TOKEN")


@bot.message(F.media_group_id)
async def handle_album(message: Message, media_group: MediaGroup):
    await message.answer_media_group(media_group)

media_group contains the collected media group messages.

Properties

Property Description
media_group.count Returns the number of media items in the group.
media_group.caption Returns the first caption found in the group (Telegram sends caption only on the first item). Returns None if no caption is present.
media_group.captions Returns a list of all captions from the group.
media_group.messages Returns a copy of the original Message objects from the group.
media_group.photos Returns a list of Message objects that contain photos.
media_group.videos Returns a list of Message objects that contain videos.
media_group.documents Returns a list of Message objects that contain documents.
media_group.audio Returns a list of Message objects that contain audio files.
media_group.is_mixed Returns True if the album contains different media types (e.g., photos and videos together).

Routers

Router connection is simplified with bot.load()

Project structure

project/
│
├── main.py
└── handlers/
    └── start.py

main.py

from re_aiogram import Bot

API_TOKEN = "YOUR_API_TOKEN"

bot = Bot(token=API_TOKEN)

bot.load("handlers.start")

bot.run(logging_enabled=True)

handlers/start.py

from re_aiogram import router, Message
from re_aiogram.filters import Command


@router.message(Command("start"))
async def start(message: Message):
    await message.answer("Router connected!")

Future improvements

These features are planned for upcoming versions and are not yet part of the core API.

Flow System (FSM alternative)

A lightweight state/flow system replacing traditional FSM:

  • step-based flow control
  • ctx.next() and ctx.back()
  • shared ctx.data
  • parallel flows via scope()
  • simple chain-based conversation handling

Example concept:

@router.message(Command("register"))
async def register(message: Message, ctx: FlowContext):
    await message.answer("What is your name?")
    ctx.next(get_name)

Philosophy

re_aiogram tries to make Telegram bot development:

  • simpler
  • cleaner
  • less boilerplate-heavy
  • more beginner-friendly

while still preserving compatibility with the aiogram ecosystem.


License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

re_aiogram-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

re_aiogram-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file re_aiogram-0.1.1.tar.gz.

File metadata

  • Download URL: re_aiogram-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for re_aiogram-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b2111142d42cc47d9e2b613818312b110567aaf636dcdf032643aa71edb08e84
MD5 e7fd01625034c7e8bbcae4820497a915
BLAKE2b-256 c46c185caac175e1d496baab6303546759714eb4be4eb784139f03ebcfb6c145

See more details on using hashes here.

File details

Details for the file re_aiogram-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: re_aiogram-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for re_aiogram-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7cd3011760b1f1f52330258d188a158dcfb9dd164fd29d10017e5e5dcb21b46
MD5 558b01142f64ede9ce0fa8454eadee5b
BLAKE2b-256 0f876949c62450832e21ebcc82d2ed9ea0d1b28702a4e611fc4ccbd25c027bae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page