Edge hygiene library for aiogram v3 with middlewares, router, and storage backends
Project description
aiogram-sentinel
Rate limiting and debouncing middleware for aiogram v3 - Protect your Telegram bots from spam and abuse with powerful middleware and storage backends.
✨ Features
- Rate Limiting: Per-user/handler scopes with sliding window algorithm
- Debouncing: Suppress duplicate messages/callbacks within a configurable window
- Storage Backends: Memory (single worker) or Redis (multi-worker) with configurable prefixes
- Decorators:
@rate_limitand@debouncefor easy handler configuration - Hooks: Optional
on_rate_limitedcallback for custom user feedback - Setup Helper:
Sentinel.setup(dp, cfg)wires middleware in recommended order - Typed, async-first, production-ready.
📦 Installation
# Basic installation
pip install aiogram-sentinel
# With Redis support
pip install aiogram-sentinel[redis]
⚡ Quick Start
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram_sentinel import Sentinel, SentinelConfig, rate_limit, debounce
# Create bot and dispatcher
bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher()
# Configure aiogram-sentinel
config = SentinelConfig(
throttling_default_max=10, # 10 messages per window
throttling_default_per_seconds=60, # 60 second window
debounce_default_window=2, # 2 second debounce
)
# Setup with one call - wires all middleware in recommended order
router, infra = await Sentinel.setup(dp, config)
# Your handlers with protection
@router.message()
@rate_limit(5, 60) # 5 messages per minute
@debounce(1.0) # 1 second debounce
async def handle_message(message: Message):
await message.answer(f"Hello! Your message: {message.text}")
# Start your bot
await dp.start_polling(bot)
📚 Documentation
👉 Full Documentation ← Start here!
- Quickstart - Get started in 5 minutes
- Configuration - Complete configuration guide
- API Reference - Full API documentation
- Tutorials - Step-by-step guides
- Performance - Benchmarks and optimization
- Examples - Complete working examples
🤝 Contributing
See CONTRIBUTING.md for development guidelines and setup instructions.
💬 Community & Support
- 💬 Discussions - Questions, ideas, and community chat
- 🐛 Issues - Bug reports and concrete feature requests
- 📖 Documentation - Complete guides and API reference
🎯 Where to Get Help
| Need Help With | Go To |
|---|---|
| Usage questions | 💬 Q&A Discussions |
| Feature suggestions | 💡 Ideas & Feature Requests |
| Bug reports | 🐛 Issues |
| General chat | 💬 General Discussion |
| Share projects | 🎉 Show and tell |
| Project updates | 📢 Announcements |
🔒 Security
For security issues, see SECURITY.md.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built for aiogram v3 - Modern Telegram Bot API framework
- Inspired by the need for robust bot protection in production environments
Project details
Release history Release notifications | RSS feed
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_sentinel-1.1.0.tar.gz.
File metadata
- Download URL: aiogram_sentinel-1.1.0.tar.gz
- Upload date:
- Size: 270.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c13d058a72c13110e6ca5e96f34bb8b95b1e88dfa241a044fca89ddcf7d50f3
|
|
| MD5 |
c9a54191500622714c3fba9620fd8f8c
|
|
| BLAKE2b-256 |
1890a45a4e5c6312a8c47a0432649259876bd7ba043a8a89933eb3e2df603e82
|
Provenance
The following attestation bundles were made for aiogram_sentinel-1.1.0.tar.gz:
Publisher:
release.yml on ArmanAvanesyan/aiogram-sentinel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_sentinel-1.1.0.tar.gz -
Subject digest:
2c13d058a72c13110e6ca5e96f34bb8b95b1e88dfa241a044fca89ddcf7d50f3 - Sigstore transparency entry: 606476690
- Sigstore integration time:
-
Permalink:
ArmanAvanesyan/aiogram-sentinel@c87c9d055e7f1a16ad85d37747330f2c3c87d7cf -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ArmanAvanesyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c87c9d055e7f1a16ad85d37747330f2c3c87d7cf -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiogram_sentinel-1.1.0-py3-none-any.whl.
File metadata
- Download URL: aiogram_sentinel-1.1.0-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3cc205ecf6ab0a0d130dd253dfb19d61f33083244012b1ed38729078ba7f8da
|
|
| MD5 |
e1b5920a4b7d5ace249a4b9bfd4ff6e4
|
|
| BLAKE2b-256 |
6c5f9dbba80b9f9e924ae2d9c85c37a1b927239a13653a44bb7d3afd0b332c4e
|
Provenance
The following attestation bundles were made for aiogram_sentinel-1.1.0-py3-none-any.whl:
Publisher:
release.yml on ArmanAvanesyan/aiogram-sentinel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_sentinel-1.1.0-py3-none-any.whl -
Subject digest:
c3cc205ecf6ab0a0d130dd253dfb19d61f33083244012b1ed38729078ba7f8da - Sigstore transparency entry: 606476692
- Sigstore integration time:
-
Permalink:
ArmanAvanesyan/aiogram-sentinel@c87c9d055e7f1a16ad85d37747330f2c3c87d7cf -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ArmanAvanesyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c87c9d055e7f1a16ad85d37747330f2c3c87d7cf -
Trigger Event:
push
-
Statement type: