Skip to main content

aiogram-sentinel

CI PyPI Python versions Docs License

More badges

Coverage Ruff Pyright Downloads

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_limit and @debounce for easy handler configuration
  • Hooks: Optional on_rate_limited callback 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!

🤝 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

Release files for aiogram-sentinel 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiogram-sentinel 1.1.0
File Size Uploaded
aiogram_sentinel-1.1.0.tar.gz 270.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiogram-sentinel 1.1.0
File Interpreter ABI Platform
aiogram_sentinel-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 304.0 kB

Release files / aiogram_sentinel-1.1.0.tar.gz

Download URL aiogram_sentinel-1.1.0.tar.gz
Size 270.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2c13d058a72c13110e6ca5e96f34bb8b95b1e88dfa241a044fca89ddcf7d50f3
BLAKE2b-256 checksum
How to use checksums
1890a45a4e5c6312a8c47a0432649259876bd7ba043a8a89933eb3e2df603e82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2025.

Transparency log

Release files / aiogram_sentinel-1.1.0-py3-none-any.whl

Download URL aiogram_sentinel-1.1.0-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3cc205ecf6ab0a0d130dd253dfb19d61f33083244012b1ed38729078ba7f8da
BLAKE2b-256 checksum
How to use checksums
6c5f9dbba80b9f9e924ae2d9c85c37a1b927239a13653a44bb7d3afd0b332c4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page