v0.3.x docs
Getting Started
v0.3.x is the foundation release — it ships two independent packages: pykeyboard for building Telegram keyboards and pyrogram_patch for routing, FSM, middleware, and storage. There is no unified namespace yet; you import from each package directly.
Installation
pip
pip install kurigram-addons==0.3.*poetry
poetry add "kurigram-addons==0.3.*"uv
uv add "kurigram-addons==0.3.*"What's in v0.3
pykeyboard
- InlineKeyboard builder
- ReplyKeyboard builder
- Pagination keyboard
- Language selection keyboard
- Builder API (fluent interface)
- Hooks & validation
- Utilities (button helpers)
pyrogram_patch
- patch() / PatchManager
- Router with filter-based handlers
- Finite State Machine (FSM)
- MemoryStorage & RedisStorage
- Before / around / after middleware
- PatchHelper (data, state in handlers)
- AsyncCircuitBreaker
- Configuration via env vars
Quick Start
bot.py
from pyrogram import Client, filters
from pyrogram_patch import patch
from pyrogram_patch.router import Router
from pyrogram_patch.fsm import StatesGroup, State, FSMContext
from pyrogram_patch.fsm.storages import MemoryStorage
from pykeyboard import InlineKeyboard, InlineButton
router = Router()
class Form(StatesGroup):
name = State()
age = State()
@router.on_message(filters.command("start"))
async def cmd_start(client, message, state: FSMContext):
await state.set_state(Form.name)
await message.reply("What's your name?")
@router.on_message(Form.name.filter())
async def got_name(client, message, state: FSMContext):
await state.update_data(name=message.text)
await state.set_state(Form.age)
await message.reply("How old are you?")
@router.on_message(Form.age.filter())
async def got_age(client, message, state: FSMContext):
data = await state.get_data()
await state.clear_state()
await message.reply(
f"Name: {data['name']}, Age: {message.text}"
)
app = Client("my_bot", bot_token="...")
manager = patch(app, storage=MemoryStorage())
manager.include_router(router)
app.run()Imports Reference
# Keyboards
from pykeyboard import (
InlineKeyboard, InlineButton,
ReplyKeyboard, ReplyButton,
Button,
)
# Core patching
from pyrogram_patch import patch, PatchManager
# Router
from pyrogram_patch.router import Router
# FSM
from pyrogram_patch.fsm import StatesGroup, State, FSMContext
from pyrogram_patch.fsm.filters import StateFilter
from pyrogram_patch.fsm.storages import MemoryStorage, RedisStorage
# Middleware helper
from pyrogram_patch.patch_helper import PatchHelper