Edge hygiene library for aiogram v3 with middlewares, router, and storage backends
Project description
aiogram-sentinel
Drop-in middlewares for aiogram v3 with batteries included - Protect your Telegram bots from spam, abuse, and unwanted behavior with powerful middleware and storage backends.
✨ Features
- Auth bootstrap with pluggable resolver → expose
data["user_context"]without locking you to a DB. - Blocking: deny early if user is blocked; auto-sync block/unblock via
my_chat_member, withon_block/on_unblockhooks. - Debouncing: suppress duplicate messages/callbacks within a window.
- Throttling: per-user/handler scopes; notifier hook for UX.
- Backends: memory (single worker) or redis (multi-worker), with configurable
redis_prefix. - Setup helper:
Sentinel.setup(dp, cfg)wires recommended order and membership router. - 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_sentinel import Sentinel, SentinelConfig
# 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
)
# Setup with one call - wires all middleware in recommended order
sentinel = Sentinel(config=config)
dp.message.middleware(sentinel.middleware)
# Your handlers now have access to user context
@dp.message()
async def handle_message(message, data):
user_context = data["user_context"] # Available after auth middleware
await message.answer(f"Hello {user_context['username']}!")
# Start your bot
await dp.start_polling(bot)
📚 Documentation
- Quickstart - Get started in 5 minutes
- Configuration - Complete configuration guide
- API Reference - Full API documentation
- Tutorials - Step-by-step guides
- Performance - Benchmarks and optimization
- Migration Guides - Upgrade instructions
- Roadmap - Future plans and features
- Examples - Complete working examples
🤝 Contributing
See CONTRIBUTING.md for development guidelines and setup instructions.
🔒 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-0.1.0.tar.gz.
File metadata
- Download URL: aiogram_sentinel-0.1.0.tar.gz
- Upload date:
- Size: 261.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7416681c464082050e0384ee494a236d8776dfc45359e2749e403d558c5c3438
|
|
| MD5 |
5a6ed15c61beee6b39558c791afb4965
|
|
| BLAKE2b-256 |
a67f51a458e3746d905c6d7d00400a6b23e7d7cc586615a693435a4689dece82
|
Provenance
The following attestation bundles were made for aiogram_sentinel-0.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-0.1.0.tar.gz -
Subject digest:
7416681c464082050e0384ee494a236d8776dfc45359e2749e403d558c5c3438 - Sigstore transparency entry: 566632254
- Sigstore integration time:
-
Permalink:
ArmanAvanesyan/aiogram-sentinel@68789b0347650e1ba461ed68c2e7037d1d8765f2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ArmanAvanesyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@68789b0347650e1ba461ed68c2e7037d1d8765f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiogram_sentinel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiogram_sentinel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.3 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 |
556b4c36641acfe2ccb204bd4d52b3974d1f6df84cad076142bea52c1ef3e99f
|
|
| MD5 |
f3a0a84e11ba9ae0774fef920f033a18
|
|
| BLAKE2b-256 |
37a70da0a00311fd34efcb0807d3d0b8001e706ce53fc9088a43ee4a63c8c366
|
Provenance
The following attestation bundles were made for aiogram_sentinel-0.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-0.1.0-py3-none-any.whl -
Subject digest:
556b4c36641acfe2ccb204bd4d52b3974d1f6df84cad076142bea52c1ef3e99f - Sigstore transparency entry: 566632259
- Sigstore integration time:
-
Permalink:
ArmanAvanesyan/aiogram-sentinel@68789b0347650e1ba461ed68c2e7037d1d8765f2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ArmanAvanesyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@68789b0347650e1ba461ed68c2e7037d1d8765f2 -
Trigger Event:
push
-
Statement type: