shirdal 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. shirdal-1.0.0/.github/workflows/ci.yml +22 -0
  2. shirdal-1.0.0/.github/workflows/workflow.yml +25 -0
  3. shirdal-1.0.0/.gitignore +18 -0
  4. shirdal-1.0.0/CHANGELOG.md +14 -0
  5. shirdal-1.0.0/LICENSE +8 -0
  6. shirdal-1.0.0/PKG-INFO +117 -0
  7. shirdal-1.0.0/README.fa.md +49 -0
  8. shirdal-1.0.0/README.md +73 -0
  9. shirdal-1.0.0/examples/quickstart_selfbot/main.py +19 -0
  10. shirdal-1.0.0/examples/quickstart_selfbot/plugins/auto_clock.py +10 -0
  11. shirdal-1.0.0/examples/quickstart_selfbot/plugins/essentials.py +19 -0
  12. shirdal-1.0.0/examples/quickstart_selfbot/plugins/wizard.py +17 -0
  13. shirdal-1.0.0/pyproject.toml +61 -0
  14. shirdal-1.0.0/src/shirdal/__init__.py +115 -0
  15. shirdal-1.0.0/src/shirdal/cli.py +145 -0
  16. shirdal-1.0.0/src/shirdal/client.py +156 -0
  17. shirdal-1.0.0/src/shirdal/core/__init__.py +35 -0
  18. shirdal-1.0.0/src/shirdal/core/adapter.py +167 -0
  19. shirdal-1.0.0/src/shirdal/core/events.py +66 -0
  20. shirdal-1.0.0/src/shirdal/core/hydrogram_adapter.py +329 -0
  21. shirdal-1.0.0/src/shirdal/core/mock_adapter.py +290 -0
  22. shirdal-1.0.0/src/shirdal/core/telethon_adapter.py +378 -0
  23. shirdal-1.0.0/src/shirdal/engine/__init__.py +42 -0
  24. shirdal-1.0.0/src/shirdal/engine/context.py +311 -0
  25. shirdal-1.0.0/src/shirdal/engine/dispatcher.py +117 -0
  26. shirdal-1.0.0/src/shirdal/engine/filters.py +151 -0
  27. shirdal-1.0.0/src/shirdal/engine/fsm.py +95 -0
  28. shirdal-1.0.0/src/shirdal/engine/media.py +121 -0
  29. shirdal-1.0.0/src/shirdal/engine/scheduler.py +121 -0
  30. shirdal-1.0.0/src/shirdal/guard/__init__.py +10 -0
  31. shirdal-1.0.0/src/shirdal/guard/antiflood.py +322 -0
  32. shirdal-1.0.0/src/shirdal/guard/middleware.py +16 -0
  33. shirdal-1.0.0/src/shirdal/multi.py +116 -0
  34. shirdal-1.0.0/src/shirdal/plugins/__init__.py +3 -0
  35. shirdal-1.0.0/src/shirdal/plugins/loader.py +149 -0
  36. shirdal-1.0.0/src/shirdal/py.typed +0 -0
  37. shirdal-1.0.0/src/shirdal/storage/__init__.py +14 -0
  38. shirdal-1.0.0/src/shirdal/storage/base.py +14 -0
  39. shirdal-1.0.0/src/shirdal/storage/crypto.py +96 -0
  40. shirdal-1.0.0/src/shirdal/storage/mysql.py +220 -0
  41. shirdal-1.0.0/src/shirdal/storage/redis.py +117 -0
  42. shirdal-1.0.0/src/shirdal/storage/sqlite.py +207 -0
  43. shirdal-1.0.0/tests/test_phase10_redis_crypto.py +84 -0
  44. shirdal-1.0.0/tests/test_phase11_cli.py +35 -0
  45. shirdal-1.0.0/tests/test_phase12_release.py +47 -0
  46. shirdal-1.0.0/tests/test_phase13_polish.py +49 -0
  47. shirdal-1.0.0/tests/test_phase14_moderation_cache.py +60 -0
  48. shirdal-1.0.0/tests/test_phase15_release_checklist.py +20 -0
  49. shirdal-1.0.0/tests/test_phase16_mysql_sqlite_tuning.py +98 -0
  50. shirdal-1.0.0/tests/test_phase17_uploader.py +59 -0
  51. shirdal-1.0.0/tests/test_phase18_device_profile.py +13 -0
  52. shirdal-1.0.0/tests/test_phase1_core.py +35 -0
  53. shirdal-1.0.0/tests/test_phase2_engine.py +66 -0
  54. shirdal-1.0.0/tests/test_phase3_antiflood.py +76 -0
  55. shirdal-1.0.0/tests/test_phase4_plugins.py +74 -0
  56. shirdal-1.0.0/tests/test_phase5_fsm_middleware.py +108 -0
  57. shirdal-1.0.0/tests/test_phase6_storage.py +86 -0
  58. shirdal-1.0.0/tests/test_phase7_multibot.py +52 -0
  59. shirdal-1.0.0/tests/test_phase8_media_adapters.py +68 -0
  60. shirdal-1.0.0/tests/test_phase9_scheduler.py +51 -0
@@ -0,0 +1,22 @@
1
+ name: Shirdal CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - name: Run unit tests
22
+ run: PYTHONPATH=src python3 -m unittest discover -s tests -v
@@ -0,0 +1,25 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+ - name: Install build tools
19
+ run: python -m pip install --upgrade pip build
20
+ - name: Run test suite
21
+ run: PYTHONPATH=src python -m unittest discover -s tests -v
22
+ - name: Build package
23
+ run: python -m build
24
+ - name: Publish to PyPI
25
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+ .env
11
+ *.session
12
+ *.session-journal
13
+ *.db
14
+ *.db-wal
15
+ *.db-shm
16
+ .mypy_cache/
17
+ .ruff_cache/
18
+ .pytest_cache/
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2026-11-26
4
+
5
+ ### Added
6
+ - **Core Adapter Layer:** `TransportAdapter` protocol with `MockAdapter`, `TelethonAdapter`, and `HydrogramAdapter`.
7
+ - **Context-First Engine:** `Context` (`reply`, `edit`, `send`, `reply_media`, `download`, `react`, `pin`, `ban`, `unban`, `mute`, `kick`, `get_chat`, `typing`, `auto_delete`).
8
+ - **Composable Filters:** `command`, `regex`, `state`, `outgoing`, `incoming`, `private`, `group`, `reply`, `text` with `&`, `|`, `~`.
9
+ - **Anti-Flood Guard:** `AntiFloodAdapter` with per-chat pacing, global cooldown, and automatic `FloodWaitError` recovery.
10
+ - **Hot-Reload Plugins:** `PluginManager` with `setup(bot)`/`teardown(bot)` and live file-mtime watching without disconnecting.
11
+ - **Middleware & FSM:** Onion-style `Middleware` pipeline and `StatesGroup` / `FSMStorage`.
12
+ - **Storage & Encryption:** `SQLiteStorage` (WAL + L1 cache), `RedisStorage`, and `EncryptedStorage` (`SecretBox`).
13
+ - **MultiBot & Scheduler:** Concurrent `MultiBot` fleet runner, `@bot.every(...)` periodic scheduler, and `@bot.on_error`.
14
+ - **Developer CLI:** `shirdal new`, `shirdal doctor`, and `shirdal run`.
shirdal-1.0.0/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE (LGPL-3.0-or-later)
2
+
3
+ Copyright (c) 2026 Vicious-Cycle / Shirdal Contributors
4
+
5
+ This library is free software; you can redistribute it and/or modify it under
6
+ the terms of the GNU Lesser General Public License as published by the Free
7
+ Software Foundation; either version 3 of the License, or (at your option) any
8
+ later version. See <https://www.gnu.org/licenses/lgpl-3.0.html> for full terms.
shirdal-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: shirdal
3
+ Version: 1.0.0
4
+ Summary: A fast, clean, context-first Python self-bot framework for Telegram.
5
+ Project-URL: Homepage, https://github.com/Vicious-Cycle/shirdal
6
+ Project-URL: Repository, https://github.com/Vicious-Cycle/shirdal
7
+ Project-URL: Issues, https://github.com/Vicious-Cycle/shirdal/issues
8
+ Author: Vicious-Cycle
9
+ License: LGPL-3.0-or-later
10
+ License-File: LICENSE
11
+ Keywords: asyncio,framework,mtproto,selfbot,telegram
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.11
19
+ Provides-Extra: all
20
+ Requires-Dist: aiomysql>=0.2.0; extra == 'all'
21
+ Requires-Dist: msgspec>=0.18.6; extra == 'all'
22
+ Requires-Dist: redis>=5.0.0; extra == 'all'
23
+ Requires-Dist: telethon>=1.36.0; extra == 'all'
24
+ Requires-Dist: uvloop>=0.19.0; (sys_platform != 'win32') and extra == 'all'
25
+ Provides-Extra: crypto
26
+ Requires-Dist: cryptography>=42.0.0; extra == 'crypto'
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
29
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
32
+ Provides-Extra: fast
33
+ Requires-Dist: msgspec>=0.18.6; extra == 'fast'
34
+ Requires-Dist: uvloop>=0.19.0; (sys_platform != 'win32') and extra == 'fast'
35
+ Provides-Extra: hydrogram
36
+ Requires-Dist: hydrogram>=0.2.0; extra == 'hydrogram'
37
+ Provides-Extra: mysql
38
+ Requires-Dist: aiomysql>=0.2.0; extra == 'mysql'
39
+ Provides-Extra: redis
40
+ Requires-Dist: redis>=5.0.0; extra == 'redis'
41
+ Provides-Extra: telethon
42
+ Requires-Dist: telethon>=1.36.0; extra == 'telethon'
43
+ Description-Content-Type: text/markdown
44
+
45
+ <div align="center">
46
+
47
+ # Shirdal
48
+
49
+ **A fast, clean, context-first Python self-bot framework for Telegram.**
50
+
51
+ **English** | [فارسی](README.fa.md)
52
+
53
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
54
+ [![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](LICENSE)
55
+
56
+ </div>
57
+
58
+ ## Features
59
+
60
+ - **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.
61
+ - **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():`.
62
+ - **Composable Filters:** Combine `command`, `regex`, `state`, `outgoing`, `incoming`, `private`, `group`, `reply`, and `text` using `&`, `|`, and `~`.
63
+ - **Smart Anti-Flood Guard:** Per-chat pacing, concurrency limits, global cooldown propagation, and automatic `FloodWaitError` recovery.
64
+ - **Live Hot-Reload Plugins:** Drop `.py` modules with `setup(bot)` / `teardown(bot)` into `plugins/` and reload on save without dropping the Telegram connection.
65
+ - **Middleware & FSM:** Onion-style `@bot.use` middlewares, global `@bot.on_error` handlers, and `StatesGroup` multi-step flows.
66
+ - **Storage & Encryption:** Tuned WAL-mode `SQLiteStorage` (with L1 RAM cache), `RedisStorage`, `MySQLStorage`, and `EncryptedStorage` (`Encrypt-then-MAC`).
67
+ - **MultiBot & Scheduler:** Run multiple accounts concurrently under `MultiBot` and schedule periodic tasks with `@bot.every(...)`.
68
+ - **Uploader Optimizations:** Throttled `ProgressTracker` and bounded `TransferQueue`.
69
+ - **Developer CLI:** `shirdal new`, `shirdal doctor`, and `shirdal run`.
70
+
71
+ ## Installation
72
+
73
+ ```bash
74
+ pip install shirdal
75
+ # With Telethon + uvloop:
76
+ pip install "shirdal[telethon,fast]"
77
+ ```
78
+
79
+ ## Quickstart
80
+
81
+ ```python
82
+ import os
83
+ from shirdal import Context, DeviceProfile, SelfBot, SQLiteStorage, TelethonAdapter, command, outgoing
84
+
85
+ adapter = TelethonAdapter(
86
+ "my_account",
87
+ int(os.environ["API_ID"]),
88
+ os.environ["API_HASH"],
89
+ device=DeviceProfile.desktop(),
90
+ )
91
+
92
+ bot = SelfBot(
93
+ adapter,
94
+ anti_flood=True,
95
+ plugins_dir="plugins",
96
+ hot_reload=True,
97
+ storage=SQLiteStorage("shirdal.db"),
98
+ )
99
+
100
+ @bot.on(command("ping") & outgoing)
101
+ async def ping(ctx: Context) -> None:
102
+ msg = await ctx.edit("Checking...")
103
+ await msg.edit("Pong!", auto_delete=10)
104
+
105
+ if __name__ == "__main__":
106
+ bot.run()
107
+ ```
108
+
109
+ ## Running Tests
110
+
111
+ ```bash
112
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
113
+ ```
114
+
115
+ ## License
116
+
117
+ Licensed under the [LGPL-3.0-or-later](LICENSE).
@@ -0,0 +1,49 @@
1
+ <div align="center" dir="rtl">
2
+
3
+ # Shirdal (شیر‌دال)
4
+
5
+ **فریم‌ورک سریع، تمیز و Context-First پایتون برای ساخت سلف‌بات‌های تلگرام**
6
+
7
+ [English](README.md) | **فارسی**
8
+
9
+ </div>
10
+
11
+ ## ویژگی‌های کلیدی
12
+
13
+ - **هسته آداپتور (`TransportAdapter`):** مستقل از موتور MTProto زیرین، همراه با `TelethonAdapter`، `HydrogramAdapter`، پروفایل دستگاه تمیز (`DeviceProfile`)، پشتیبانی از `StringSession` و `MockAdapter` برای تست بدون نیاز به اکانت.
14
+ - **رابط تمیز `Context`:** متدهای `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()`، `auto_delete` غیرمسدودکننده و `async with ctx.typing():`.
15
+ - **فیلترهای ترکیبی:** ترکیب `command`، `regex`، `state`، `outgoing`، `incoming`، `private`، `group`، `reply` و `text` با عملگرهای `&`، `|` و `~`.
16
+ - **محافظ ضدبلاک (`AntiFloodAdapter`):** فاصله‌گذاری خودکار به ازای هر چت، کنترل هم‌زمانی و بازیابی هوشمند `FloodWaitError`.
17
+ - **پلاگین‌های `Hot-Reload`:** بارگذاری و به‌روزرسانی زنده ماژول‌های `plugins/` بدون قطع اتصال اکانت.
18
+ - **میدل‌ور و ماشین وضعیت (`FSM`):** پایپ‌لاین `@bot.use`، مدیریت خطای سراسری `@bot.on_error` و `StatesGroup`.
19
+ - **ذخیره‌سازی و رمزنگاری:** `SQLiteStorage` (حالت `WAL` بهینه + کش L1)، `RedisStorage`، `MySQLStorage` و `EncryptedStorage`.
20
+ - **اجرای چنداکانتی و زمان‌بند:** مدیریت هم‌زمان اکانت‌ها با `MultiBot` و اجرای دوره‌ای با `@bot.every(...)`.
21
+ - **بهینه برای آپلودرها:** `ProgressTracker` ضداسپم و `TransferQueue` برای کنترل صف آپلود و دانلود.
22
+ - **ابزار خط فرمان (`CLI`):** دستورات `shirdal new`، `shirdal doctor` و `shirdal run`.
23
+
24
+ ## نصب
25
+
26
+ ```bash
27
+ pip install shirdal
28
+ # همراه با Telethon و uvloop:
29
+ pip install "shirdal[telethon,fast]"
30
+ ```
31
+
32
+ ## شروع سریع
33
+
34
+ ```bash
35
+ shirdal new my_selfbot --adapter telethon
36
+ cd my_selfbot
37
+ shirdal doctor
38
+ shirdal run main.py
39
+ ```
40
+
41
+ ## اجرای تست‌ها
42
+
43
+ ```bash
44
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
45
+ ```
46
+
47
+ ## لایسنس
48
+
49
+ منتشرشده تحت لایسنس [LGPL-3.0-or-later](LICENSE).
@@ -0,0 +1,73 @@
1
+ <div align="center">
2
+
3
+ # Shirdal
4
+
5
+ **A fast, clean, context-first Python self-bot framework for Telegram.**
6
+
7
+ **English** | [فارسی](README.fa.md)
8
+
9
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
10
+ [![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](LICENSE)
11
+
12
+ </div>
13
+
14
+ ## Features
15
+
16
+ - **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.
17
+ - **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():`.
18
+ - **Composable Filters:** Combine `command`, `regex`, `state`, `outgoing`, `incoming`, `private`, `group`, `reply`, and `text` using `&`, `|`, and `~`.
19
+ - **Smart Anti-Flood Guard:** Per-chat pacing, concurrency limits, global cooldown propagation, and automatic `FloodWaitError` recovery.
20
+ - **Live Hot-Reload Plugins:** Drop `.py` modules with `setup(bot)` / `teardown(bot)` into `plugins/` and reload on save without dropping the Telegram connection.
21
+ - **Middleware & FSM:** Onion-style `@bot.use` middlewares, global `@bot.on_error` handlers, and `StatesGroup` multi-step flows.
22
+ - **Storage & Encryption:** Tuned WAL-mode `SQLiteStorage` (with L1 RAM cache), `RedisStorage`, `MySQLStorage`, and `EncryptedStorage` (`Encrypt-then-MAC`).
23
+ - **MultiBot & Scheduler:** Run multiple accounts concurrently under `MultiBot` and schedule periodic tasks with `@bot.every(...)`.
24
+ - **Uploader Optimizations:** Throttled `ProgressTracker` and bounded `TransferQueue`.
25
+ - **Developer CLI:** `shirdal new`, `shirdal doctor`, and `shirdal run`.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install shirdal
31
+ # With Telethon + uvloop:
32
+ pip install "shirdal[telethon,fast]"
33
+ ```
34
+
35
+ ## Quickstart
36
+
37
+ ```python
38
+ import os
39
+ from shirdal import Context, DeviceProfile, SelfBot, SQLiteStorage, TelethonAdapter, command, outgoing
40
+
41
+ adapter = TelethonAdapter(
42
+ "my_account",
43
+ int(os.environ["API_ID"]),
44
+ os.environ["API_HASH"],
45
+ device=DeviceProfile.desktop(),
46
+ )
47
+
48
+ bot = SelfBot(
49
+ adapter,
50
+ anti_flood=True,
51
+ plugins_dir="plugins",
52
+ hot_reload=True,
53
+ storage=SQLiteStorage("shirdal.db"),
54
+ )
55
+
56
+ @bot.on(command("ping") & outgoing)
57
+ async def ping(ctx: Context) -> None:
58
+ msg = await ctx.edit("Checking...")
59
+ await msg.edit("Pong!", auto_delete=10)
60
+
61
+ if __name__ == "__main__":
62
+ bot.run()
63
+ ```
64
+
65
+ ## Running Tests
66
+
67
+ ```bash
68
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
69
+ ```
70
+
71
+ ## License
72
+
73
+ Licensed under the [LGPL-3.0-or-later](LICENSE).
@@ -0,0 +1,19 @@
1
+ import os
2
+ from shirdal import SelfBot, SQLiteStorage, TelethonAdapter
3
+
4
+ adapter = TelethonAdapter(
5
+ os.getenv("SESSION_NAME", "my_account"),
6
+ int(os.getenv("API_ID", "0")),
7
+ os.getenv("API_HASH", ""),
8
+ )
9
+
10
+ bot = SelfBot(
11
+ adapter,
12
+ anti_flood=True,
13
+ plugins_dir="plugins",
14
+ hot_reload=True,
15
+ storage=SQLiteStorage("shirdal.db"),
16
+ )
17
+
18
+ if __name__ == "__main__":
19
+ bot.run()
@@ -0,0 +1,10 @@
1
+ from datetime import datetime
2
+ from shirdal import SelfBot
3
+
4
+
5
+ def setup(bot: SelfBot) -> None:
6
+ @bot.every(minutes=1)
7
+ async def tick_clock() -> None:
8
+ _now = datetime.now().strftime("%H:%M")
9
+ # Example: update profile bio or status using bot.adapter.invoke(...)
10
+ _ = _now
@@ -0,0 +1,19 @@
1
+ from shirdal import AntiFloodAdapter, Context, SelfBot, command, outgoing
2
+
3
+
4
+ def setup(bot: SelfBot) -> None:
5
+ @bot.on(command("ping") & outgoing)
6
+ async def ping_cmd(ctx: Context) -> None:
7
+ msg = await ctx.edit("⚡ Measuring...")
8
+ await msg.edit("🏓 Pong! Shirdal v1.0.0", auto_delete=10)
9
+
10
+ @bot.on(command("stats") & outgoing)
11
+ async def stats_cmd(ctx: Context) -> None:
12
+ if isinstance(bot.adapter, AntiFloodAdapter):
13
+ s = bot.adapter.stats
14
+ await ctx.edit(
15
+ f"📊 Requests: {s.total_requests} | FloodWaits: {s.flood_waits_handled}",
16
+ auto_delete=15,
17
+ )
18
+ else:
19
+ await ctx.edit("📊 AntiFlood is disabled.", auto_delete=10)
@@ -0,0 +1,17 @@
1
+ from shirdal import Context, SelfBot, State, StatesGroup, command, outgoing, state
2
+
3
+
4
+ class NoteWizard(StatesGroup):
5
+ waiting_body = State()
6
+
7
+
8
+ def setup(bot: SelfBot) -> None:
9
+ @bot.on(state(None) & command("note") & outgoing)
10
+ async def start_note(ctx: Context) -> None:
11
+ await ctx.state.set(NoteWizard.waiting_body)
12
+ await ctx.reply("✍️ Send the note text:")
13
+
14
+ @bot.on(state(NoteWizard.waiting_body) & outgoing)
15
+ async def save_note(ctx: Context) -> None:
16
+ await ctx.reply(f"📝 Saved note: {ctx.text}", auto_delete=10)
17
+ await ctx.state.clear()
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.21.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "shirdal"
7
+ version = "1.0.0"
8
+ description = "A fast, clean, context-first Python self-bot framework for Telegram."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "LGPL-3.0-or-later" }
12
+ authors = [{ name = "Vicious-Cycle" }]
13
+ keywords = ["telegram", "selfbot", "mtproto", "asyncio", "framework"]
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Framework :: AsyncIO",
21
+ ]
22
+ dependencies = []
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/Vicious-Cycle/shirdal"
26
+ Repository = "https://github.com/Vicious-Cycle/shirdal"
27
+ Issues = "https://github.com/Vicious-Cycle/shirdal/issues"
28
+
29
+ [project.scripts]
30
+ shirdal = "shirdal.cli:main"
31
+
32
+ [project.optional-dependencies]
33
+ fast = [
34
+ "uvloop>=0.19.0; sys_platform != 'win32'",
35
+ "msgspec>=0.18.6",
36
+ ]
37
+ telethon = ["telethon>=1.36.0"]
38
+ hydrogram = ["hydrogram>=0.2.0"]
39
+ redis = ["redis>=5.0.0"]
40
+ mysql = ["aiomysql>=0.2.0"]
41
+ crypto = ["cryptography>=42.0.0"]
42
+ all = [
43
+ "uvloop>=0.19.0; sys_platform != 'win32'",
44
+ "msgspec>=0.18.6",
45
+ "telethon>=1.36.0",
46
+ "redis>=5.0.0",
47
+ "aiomysql>=0.2.0",
48
+ ]
49
+ dev = ["pytest>=8.0.0", "pytest-asyncio>=0.23.0", "ruff>=0.4.0", "mypy>=1.10.0"]
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/shirdal"]
53
+
54
+ [tool.ruff]
55
+ line-length = 100
56
+ target-version = "py311"
57
+
58
+ [tool.mypy]
59
+ python_version = "3.11"
60
+ strict = true
61
+ warn_unused_ignores = true
@@ -0,0 +1,115 @@
1
+ from shirdal.client import SelfBot
2
+ from shirdal.core.adapter import (
3
+ AdapterError,
4
+ DeviceProfile,
5
+ FloodWaitError,
6
+ TransportAdapter,
7
+ )
8
+ from shirdal.core.events import (
9
+ ChatAction,
10
+ ChatRef,
11
+ EventType,
12
+ MediaRef,
13
+ MessageEvent,
14
+ UpdateEvent,
15
+ UserRef,
16
+ )
17
+ from shirdal.core.hydrogram_adapter import HydrogramAdapter
18
+ from shirdal.core.mock_adapter import MockAdapter
19
+ from shirdal.core.telethon_adapter import TelethonAdapter
20
+ from shirdal.engine import (
21
+ Context,
22
+ Dispatcher,
23
+ Filter,
24
+ FSMContext,
25
+ FSMStorage,
26
+ MemoryStorage,
27
+ ProgressTracker,
28
+ ScheduledJob,
29
+ Scheduler,
30
+ State,
31
+ StatesGroup,
32
+ TransferProgress,
33
+ TransferQueue,
34
+ command,
35
+ group,
36
+ incoming,
37
+ outgoing,
38
+ private,
39
+ regex,
40
+ reply,
41
+ state,
42
+ text,
43
+ )
44
+ from shirdal.guard import (
45
+ AntiFloodAdapter,
46
+ AntiFloodConfig,
47
+ FloodStats,
48
+ Middleware,
49
+ NextHandler,
50
+ )
51
+ from shirdal.multi import MultiBot
52
+ from shirdal.plugins import PluginLoadResult, PluginManager
53
+ from shirdal.storage import (
54
+ CachedChat,
55
+ EncryptedStorage,
56
+ MySQLStorage,
57
+ RedisStorage,
58
+ SecretBox,
59
+ SQLiteStorage,
60
+ )
61
+
62
+ __all__ = [
63
+ "SelfBot",
64
+ "MultiBot",
65
+ "TransportAdapter",
66
+ "DeviceProfile",
67
+ "AdapterError",
68
+ "FloodWaitError",
69
+ "EventType",
70
+ "ChatAction",
71
+ "MediaRef",
72
+ "UserRef",
73
+ "ChatRef",
74
+ "MessageEvent",
75
+ "UpdateEvent",
76
+ "MockAdapter",
77
+ "TelethonAdapter",
78
+ "HydrogramAdapter",
79
+ "Context",
80
+ "Dispatcher",
81
+ "Filter",
82
+ "State",
83
+ "StatesGroup",
84
+ "FSMStorage",
85
+ "MemoryStorage",
86
+ "FSMContext",
87
+ "Scheduler",
88
+ "ScheduledJob",
89
+ "ProgressTracker",
90
+ "TransferProgress",
91
+ "TransferQueue",
92
+ "command",
93
+ "text",
94
+ "outgoing",
95
+ "incoming",
96
+ "private",
97
+ "group",
98
+ "reply",
99
+ "regex",
100
+ "state",
101
+ "AntiFloodAdapter",
102
+ "AntiFloodConfig",
103
+ "FloodStats",
104
+ "Middleware",
105
+ "NextHandler",
106
+ "PluginManager",
107
+ "PluginLoadResult",
108
+ "SQLiteStorage",
109
+ "RedisStorage",
110
+ "MySQLStorage",
111
+ "EncryptedStorage",
112
+ "SecretBox",
113
+ "CachedChat",
114
+ ]
115
+ __version__ = "1.0.0"