Skip to main content

Edge hygiene library for aiogram v3 with middlewares, router, and storage backends

Project description

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

Project details


Download files

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

Source Distribution

aiogram_sentinel-1.1.0.tar.gz (270.2 kB view details)

Uploaded Source

Built Distribution

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

aiogram_sentinel-1.1.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

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

Hashes for aiogram_sentinel-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2c13d058a72c13110e6ca5e96f34bb8b95b1e88dfa241a044fca89ddcf7d50f3
MD5 c9a54191500622714c3fba9620fd8f8c
BLAKE2b-256 1890a45a4e5c6312a8c47a0432649259876bd7ba043a8a89933eb3e2df603e82

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_sentinel-1.1.0.tar.gz:

Publisher: release.yml on ArmanAvanesyan/aiogram-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiogram_sentinel-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiogram_sentinel-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3cc205ecf6ab0a0d130dd253dfb19d61f33083244012b1ed38729078ba7f8da
MD5 e1b5920a4b7d5ace249a4b9bfd4ff6e4
BLAKE2b-256 6c5f9dbba80b9f9e924ae2d9c85c37a1b927239a13653a44bb7d3afd0b332c4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_sentinel-1.1.0-py3-none-any.whl:

Publisher: release.yml on ArmanAvanesyan/aiogram-sentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page