Skip to main content

aiogram-buffered-router

Debounced message batching for aiogram 3. Consecutive messages from the same chat are collected into one batch and passed to a single handler.

Install

uv add aiogram-buffered-router

Usage

from aiogram import Bot, Dispatcher, F
from aiogram.types import Message
from aiogram_buffered_router import BufferedRouter

router = BufferedRouter(name="chat", interval=1.0)


@router.buffered(F.text)
async def handle_batch(messages: list[Message], data: dict[str, object]) -> None:
    bot = data["bot"]
    texts = [message.text for message in messages if message.text]
    print(bot, texts)


dispatcher = Dispatcher()
dispatcher.include_router(router)

On shutdown flush the pending batches:

await router.aclose()

Options

  • interval — debounce window in seconds, restarted on nothing; the batch is dispatched interval seconds after the first message.
  • max_size — dispatch immediately once the batch reaches this size, 0 disables the limit.
  • keychat_key (bot + chat) or thread_key (bot + chat + topic, default), or any callable returning a hashable.

Handler exceptions are logged by the aiogram_buffered_router.buffer logger and never break polling.

License

MIT

Download files

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

Source Distribution

aiogram_buffered_router-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

aiogram_buffered_router-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file aiogram_buffered_router-0.1.0.tar.gz.

File metadata

  • Download URL: aiogram_buffered_router-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiogram_buffered_router-0.1.0.tar.gz
Algorithm Hash digest
SHA256 09b2ad8448f8cdf9a492b4e9125d6f5449c0c9159a5382b158013f5b4a737b0b
MD5 8434b6406b29d08b0812ee4cc10cdc67
BLAKE2b-256 e0db9d92d008aea15f58a1698ffc9d18858a6779e415b6255807e1bdbe8b1975

See more details on using hashes here.

File details

Details for the file aiogram_buffered_router-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiogram_buffered_router-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiogram_buffered_router-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac47c754842488a97d622ac214599dd92b758db5c5f0e97cd97b7544ed62f073
MD5 dd688ab69d546d6b93e15a0d4f48ac0a
BLAKE2b-256 94fe7fed08681c46fedad80a8e4edf9f591744e0f3e9a8998a9ddb9c27fb1c2b

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 Sentry Error logging StatusPage Status page