Shirdal
A fast, context-first Python framework for Telegram Bot API and MTProto clients.
English | فارسی
Shirdal separates your bot logic from the underlying transport. Write handlers, filters, FSM flows, and plugins once, then run them on the zero-dependency BotAPIAdapter (long polling or built-in WebhookServer), TelethonAdapter, HydrogramAdapter, or MockAdapter for offline tests.
Highlights
- Zero-Dependency Bot API (
BotAPIAdapter): Keep-Alive HTTP/HTTPS client with optionalmsgspecacceleration and a built-inasyncioWebhookServer(no FastAPI or aiohttp required). - Modern Bot API (9.4 – 10.5): Colored buttons (
ButtonStyle:primary,success,danger), custom/premium emoji icons (icon,custom_emoji()),disabledbuttons,date_time(), group ephemeral replies (ctx.reply_ephemeral()), live AI draft streaming (ctx.stream()),Rich Messages(ctx.reply_rich(),ctx.stream_rich()), member tags (ctx.set_member_tag()), private chat topics, andset_my_settings(). - Pluggable MTProto (
TelethonAdapter&HydrogramAdapter): CleanDeviceProfilepresets,bot_tokenandStringSessionsupport, and automatic Pyrogram fallback. - Context-First Handlers & Filters:
ctx.reply(),ctx.edit(),ctx.answer(),ctx.reply_media(),ctx.download(),ctx.react(),ctx.pin(), moderation helpers, and composable filters (command,regex,callback,state,private,group,incoming,outgoing) using&,|,~. - Production Primitives: Per-chat
AntiFloodAdapterwithFloodWaitErrorrecovery, hot-reloadplugins/, onion middlewares,StatesGroupFSM,SQLiteStorage(WAL + L1 cache),RedisStorage,MySQLStorage,EncryptedStorage,MultiBot, and@bot.every()scheduler.
Installation
pip install shirdal
# Optional extras
pip install "shirdal[fast]" # uvloop + msgspec
pip install "shirdal[telethon,fast]" # Telethon MTProto + speedups
Quickstart (Bot API)
import os
from shirdal import (
BotAPIAdapter,
Context,
Shirdal,
button,
callback,
command,
custom_emoji,
incoming,
inline_keyboard,
)
adapter = BotAPIAdapter(os.environ["BOT_TOKEN"])
bot = Shirdal(adapter)
@bot.on(incoming & command("start", prefix="/"))
async def start(ctx: Context) -> None:
badge = custom_emoji("5368324170671202286", "✨")
kb = inline_keyboard([
[
button("Confirm", "act:ok", style="success", icon="5368324170671202286"),
button("Cancel", "act:no", style="danger"),
]
])
await ctx.reply(f"{badge} <b>Ready.</b> Choose an option:", reply_markup=kb)
@bot.on_callback(callback(prefix="act:"))
async def on_action(ctx: Context) -> None:
await ctx.answer("Updated")
await ctx.reply_ephemeral(f"Selected: <code>{ctx.callback_data}</code>")
if __name__ == "__main__":
bot.run()
Quickstart (MTProto Client)
import os
from shirdal import Context, DeviceProfile, Shirdal, SQLiteStorage, TelethonAdapter, command, outgoing
adapter = TelethonAdapter(
"my_account",
int(os.environ["API_ID"]),
os.environ["API_HASH"],
device=DeviceProfile.desktop(),
)
bot = Shirdal(adapter, plugins_dir="plugins", hot_reload=True, storage=SQLiteStorage("shirdal.db"))
@bot.on(command("ping") & outgoing)
async def ping(ctx: Context) -> None:
msg = await ctx.edit("Checking...")
await msg.edit("Pong!", auto_delete=10)
if __name__ == "__main__":
bot.run()
Documentation
- Getting Started & CLI
- Bot API Features (Colored Buttons, Emoji, Ephemeral, Streaming)
- Rich Messages Guide
- Webhook Server & Production Deployment
- مستندات فارسی
Running Tests
PYTHONPATH=src python3 -m unittest discover -s tests -v
Contributing & License
See CONTRIBUTING.md. Licensed under LGPL-3.0-or-later.
Metadata
Release files for shirdal 1.0.1
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 |
|---|---|---|---|---|
| shirdal-1.0.1.tar.gz | 63.0 kB | With provenance | Details for shirdal-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shirdal-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for shirdal-1.0.1-py3-none-any.whl |
Total release size: 117.3 kB
Release files / shirdal-1.0.1.tar.gz
| Download URL | shirdal-1.0.1.tar.gz |
|---|---|
| Size | 63.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee0a2f37398b88b317f3f3a6be17c19e2b442f7abb90656acccca8eb2f481ee0
|
|
BLAKE2b-256 checksum How to use checksums |
3d5a65782f9a99fd24496d1132c72be46907520d82bc0344753974e77dbad616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / shirdal-1.0.1-py3-none-any.whl
| Download URL | shirdal-1.0.1-py3-none-any.whl |
|---|---|
| Size | 54.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97d62579dc438ae7e80a9acde7aba5045410a93c00f935b5683da015051193b5
|
|
BLAKE2b-256 checksum How to use checksums |
53417c94e2adaacefa5956b408abe197990c2882856be305817720cd14b400e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for shirdal 1.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for shirdal-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA 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.