Getting Started
Shirdal requires Python 3.11+. BotAPIAdapter requires zero external HTTP libraries, and cryptography is included out of the box for NativeMTProtoAdapter and EncryptedStorage.
Installation
Optional extras:
pip install "shirdal[fast]" # uvloop + msgspec + shircrypt Rust acceleration
pip install "shirdal[telethon]" # Telethon MTProto adapter
pip install "shirdal[hydrogram]" # Hydrogram MTProto adapter
pip install "shirdal[redis]" # Redis FSM & cache backend
pip install "shirdal[mysql]" # MySQL FSM & cache backend
Scaffolding with the CLI
Create a Bot API project:
Create a Telethon selfbot or bot project:
Core Architecture
Every Shirdal instance wraps a TransportAdapter:
BotAPIAdapter— Keep-Alive HTTP/HTTPS client for Bot API 10.5 (long polling or built-inWebhookServer).NativeMTProtoAdapter— Built-in MTProto 2.0 client (Layer 234) for user accounts and bots withshircryptRust acceleration.HybridAdapter— Runs Bot API andNativeMTProtoAdapterside by side, automatically routing> 50 MiBmedia uploads through MTProto.TelethonAdapter— MTProto client supporting both user accounts (StringSession) andbot_token.HydrogramAdapter— Hydrogram MTProto client with automatic Pyrogram fallback andbot_tokensupport.MockAdapter— In-memory adapter for deterministic unit tests without network calls.
Organize handlers with modular Routers, @router.on_command("start"), and await ctx.ask() conversations. Handlers receive a Context (ctx) object with ctx.reply(), ctx.edit(), ctx.answer(), ctx.state, ctx.args, and ctx.match, and can be filtered with the magic filter F (F.text.startswith(...)) or classic combinators (command, regex, callback, state, private, group, incoming, outgoing, reply, text) using &, |, and ~.