TelePulse
TelePulse is a lightweight, zero-dependency Python toolkit providing memory-bounded anti-flood rate limiting and generation-guarded scoped async timers for Telegram bots (aiogram, pyTelegramBotAPI, python-telegram-bot, or custom webhook handlers).
Why TelePulse?
Group and game Telegram bots frequently suffer from two reliability bottlenecks:
- Button & Command Spam: Users rapidly tapping inline buttons or spamming commands, triggering Telegram
429 Too Many Requestserrors or duplicate database writes. - Stale / Overlapping Timers: Round or session timers that fire after a game has already restarted or ended, causing ghost notifications and race conditions.
TelePulse solves both with pure Python standard library primitives (time.monotonic, collections.deque, asyncio).
Installation
pip install telepulse
Quick Start
1. Anti-Flood Decorator (@throttle)
from aiogram import Router, types
from telepulse import LimitResult, throttle
router = Router()
async def on_spam(message: types.Message, result: LimitResult) -> None:
await message.answer(f"Too fast! Try again in {result.retry_after}s.")
@router.message()
@throttle(rate=3, per=5.0, block_for=10.0, on_limited=on_spam)
async def handle_message(message: types.Message) -> None:
await message.answer("Action accepted!")
2. Generation-Guarded Scoped Timers (ScopedTimerManager)
from telepulse import ScopedTimerManager
timers = ScopedTimerManager()
async def finish_round(chat_id: int, round_id: int) -> None:
print(f"Chat {chat_id}: Round {round_id} ended!")
timers.schedule("chat:-100123:round", 30.0, finish_round, -100123, 1)
timers.schedule("chat:-100123:round", 30.0, finish_round, -100123, 2)
Running Tests
PYTHONPATH=src python -m unittest discover -s tests -v
License
MIT License — see LICENSE for details.
Metadata
Release files for telepulse 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telepulse-0.1.0.tar.gz | 6.7 kB | Without provenance | Details for telepulse-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telepulse-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for telepulse-0.1.0-py3-none-any.whl |
Total release size: 13.5 kB
Release files / telepulse-0.1.0.tar.gz
| Download URL | telepulse-0.1.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
545e875952d8890fdb24edbb2b1a3517638f7661bac20e9c0682e66405420552
|
|
BLAKE2b-256 checksum How to use checksums |
589d2fb0f548006770df1eba5b430b34773e5c2a6d0fd0e5b84b187cc14a1031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Release files / telepulse-0.1.0-py3-none-any.whl
| Download URL | telepulse-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8a177027a45685e51abba101193f414fe0905663fd643540dbf8a80d4507836
|
|
BLAKE2b-256 checksum How to use checksums |
f6757cc2b2ae8d34daa7564093e2731aa5de123c8fce68130732a9933d9e0286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Security for telepulse 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.