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 dispatchedintervalseconds after the first message.max_size— dispatch immediately once the batch reaches this size,0disables the limit.key—chat_key(bot + chat) orthread_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09b2ad8448f8cdf9a492b4e9125d6f5449c0c9159a5382b158013f5b4a737b0b
|
|
| MD5 |
8434b6406b29d08b0812ee4cc10cdc67
|
|
| BLAKE2b-256 |
e0db9d92d008aea15f58a1698ffc9d18858a6779e415b6255807e1bdbe8b1975
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac47c754842488a97d622ac214599dd92b758db5c5f0e97cd97b7544ed62f073
|
|
| MD5 |
dd688ab69d546d6b93e15a0d4f48ac0a
|
|
| BLAKE2b-256 |
94fe7fed08681c46fedad80a8e4edf9f591744e0f3e9a8998a9ddb9c27fb1c2b
|