Skip to main content

Shirdal

A fast, clean, context-first Python self-bot framework for Telegram.

English | فارسی

Python 3.11+ License: LGPL v3

Features

  • Pluggable MTProto Core (TransportAdapter): Decoupled from the underlying client, shipping with TelethonAdapter, HydrogramAdapter, DeviceProfile presets, StringSession support, and an in-memory MockAdapter for offline testing.
  • Context-First API (ctx): Ergonomic ctx.reply(), ctx.edit(), ctx.reply_media(), ctx.reply_album(), ctx.download(), ctx.react(), ctx.pin(), ctx.ban(), ctx.mute(), ctx.kick(), ctx.get_chat(), non-blocking auto_delete, and async with ctx.typing():.
  • Composable Filters: Combine command, regex, state, outgoing, incoming, private, group, reply, and text using &, |, and ~.
  • Smart Anti-Flood Guard: Per-chat pacing, concurrency limits, global cooldown propagation, and automatic FloodWaitError recovery.
  • Live Hot-Reload Plugins: Drop .py modules with setup(bot) / teardown(bot) into plugins/ and reload on save without dropping the Telegram connection.
  • Middleware & FSM: Onion-style @bot.use middlewares, global @bot.on_error handlers, and StatesGroup multi-step flows.
  • Storage & Encryption: Tuned WAL-mode SQLiteStorage (with L1 RAM cache), RedisStorage, MySQLStorage, and EncryptedStorage (Encrypt-then-MAC).
  • MultiBot & Scheduler: Run multiple accounts concurrently under MultiBot and schedule periodic tasks with @bot.every(...).
  • Uploader Optimizations: Throttled ProgressTracker and bounded TransferQueue.
  • Developer CLI: shirdal new, shirdal doctor, and shirdal run.

Installation

pip install shirdal
# With Telethon + uvloop:
pip install "shirdal[telethon,fast]"

Quickstart

import os
from shirdal import Context, DeviceProfile, SelfBot, SQLiteStorage, TelethonAdapter, command, outgoing

adapter = TelethonAdapter(
    "my_account",
    int(os.environ["API_ID"]),
    os.environ["API_HASH"],
    device=DeviceProfile.desktop(),
)

bot = SelfBot(
    adapter,
    anti_flood=True,
    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()

Running Tests

PYTHONPATH=src python3 -m unittest discover -s tests -v

License

Licensed under the LGPL-3.0-or-later.

Metadata

Release files for shirdal 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shirdal 1.0.0
File Size Uploaded Provenance Actions
shirdal-1.0.0.tar.gz 36.5 kB With provenance Details for shirdal-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shirdal 1.0.0
File Interpreter ABI Platform Actions
shirdal-1.0.0-py3-none-any.whl Python 3 none any Details for shirdal-1.0.0-py3-none-any.whl

Total release size: 76.7 kB

Release files / shirdal-1.0.0.tar.gz

Download URL shirdal-1.0.0.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d38f8a1f3196bf553dbd0e2840984987ba762f440e5eaf11886127136eea55cc
BLAKE2b-256 checksum
How to use checksums
5d3e9479d70fa370dda82ce56aa3d638a97cb1378f8c4c85faa841d620db3d40
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 log

Release files / shirdal-1.0.0-py3-none-any.whl

Download URL shirdal-1.0.0-py3-none-any.whl
Size 40.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b968a8eb6c6417609be8b96cc592b2a4c0ac007d64e7fb4546ac456c3898e871
BLAKE2b-256 checksum
How to use checksums
e85885bd075aee1e1edc9c47280df602798ab137beb8662679d3f825b86bb30c
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 log

Security for shirdal 1.0.0

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.

Select from 2 files

Attestation for shirdal-1.0.0.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page