kurigram-addons

kurigram-addons

A production-grade toolkit for building Telegram bots with Kurigram/Pyrogram. All-in-one client, declarative keyboards, conversations, dependency injection, FSM with SQLite/Redis persistence, middleware pipelines, i18n, broadcasting, testing utilities, and health monitoring.

🤖

KurigramClient

Drop-in Client subclass with built-in middleware, FSM, routing, FloodWait handling, lifecycle hooks, and HTTP health server — replaces the legacy patch() API.

⌨️

Keyboards & CallbackData

Type-safe, declarative keyboard framework with inline/reply keyboards, pagination, language selection, builder API, and strongly-typed CallbackData factory for safe callback routing.

💬

Conversations

Class-based multi-step conversations with declarative state definitions, auto-registered handlers, type-safe context passing, and inactivity timeouts.

🔧

Routing & FSM

Hierarchical routers with regex capture group injection, finite state machines with CAS-protected transitions, state history ring-buffer, and State.filter() shorthand.

📦

Storage Backends

Pluggable FSM storage — MemoryStorage for development, SQLiteStorage for zero-infra persistence, and RedisStorage with circuit breaker for production.

💉

Dependency Injection

DIContainer with FastAPI-style Depends() marker. Register providers by type — async generators, functions, values, or classes — and inject into handlers automatically.

📢

Broadcast

Async-generator bulk sender with automatic FloodWait absorption, per-user result streaming, and silent skip of blocked/deactivated users.

🌍

i18n & Testing

I18nMiddleware auto-detects user language and injects _() translator. Testing module provides MockClient, factory functions, and ConversationTester for unit testing without Telegram.

Quick Install

# Using pip
pip install kurigram-addons

# With all optional backends
pip install kurigram-addons[all]

# Using Poetry
poetry add kurigram-addons

Requirements

Python
≥ 3.10
Kurigram
≥ 2.1.35
Pydantic
≥ 2.11.7
Version
0.5.0

Redis ≥ 6.0.0 and aiosqlite ≥ 0.22.1 are optional — install with [redis], [sqlite], or [all].