Shirdal
Shirdal is a modern, context-first asynchronous Python framework for Telegram — uniting Bot API 10.5 and a Native MTProto 2.0 client (accelerated by Rust shircrypt) behind one clean TransportAdapter interface.
Documentation: English · فارسی · Download Full Docs (.md)
Features
- Unified Bot API & MTProto 2.0: Write handlers once and run them on
BotAPIAdapter,NativeMTProtoAdapter,TelethonAdapter,HydrogramAdapter, orHybridAdapter. - Rust-Accelerated Crypto (
shircrypt): Up to 11.84x faster (4.67x geometric mean) thanTgCrypto, with GIL release on large buffers and native MTProto 2.0 KDF. - Modular Routers & Magic Filter
F: Organize large bots with nestableRouters and zero-dependencyF.text.startswith(...)expressions. - Full FSM +
await ctx.ask(): DeclarativeStatesGroup,FSMStrategy, TTL-enabledMemoryStorage/RedisStorage/SQLiteStorage, plus one-linectx.ask()conversations. - Production Ready: Built-in
AntiFloodAdapter,WebhookServer,Hot-Reloadplugins,MultiBot, andMockAdapterfor offline testing.
Startup Diagnostics
On startup, Shirdal measures connection latency and prints active extensions:
Simple Usage
import os
from shirdal import BotAPIAdapter, Context, F, Router, Shirdal
router = Router("main")
@router.on_command("start")
async def start(ctx: Context) -> None:
name_ctx = await ctx.ask("What is your name?", timeout=60, filters=F.text)
await name_ctx.reply(f"Hello <b>{name_ctx.text}</b>!")
if __name__ == "__main__":
bot = Shirdal(BotAPIAdapter(os.environ["BOT_TOKEN"]))
bot.include_router(router)
bot.run()
Full Documentation Index
Getting Started & Core
- Getting Started & CLI
- Bot API 10.5 Features
- Rich Messages & Streaming
- Native MTProto 2.0 Core
- Hybrid Mode (Bot API + 50MB+ MTProto Uploads)
Routing, Filters & FSM
Production, Tooling & Migration
- Middlewares, Anti-Flood & Error Handling
- Plugins, Hot-Reload & Scheduler
- MultiBot & Encrypted Storage
- Offline Testing (
MockAdapter) & CLI - Webhook & Deployment
- Migrating from aiogram / Pyrogram
- Changelog
API Reference
- Client, Router & MultiBot API
- Context & FSM API
- Adapters API (
BotAPIAdapter,NativeMTProtoAdapter,HybridAdapter,MockAdapter) - Filters, Guard & Storage API