pytgflow 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 (163) hide show
  1. pytgflow-1.0.0/CHANGELOG.md +67 -0
  2. pytgflow-1.0.0/LICENSE +21 -0
  3. pytgflow-1.0.0/MANIFEST.in +13 -0
  4. pytgflow-1.0.0/PKG-INFO +175 -0
  5. pytgflow-1.0.0/README.md +135 -0
  6. pytgflow-1.0.0/build.sh +16 -0
  7. pytgflow-1.0.0/docs/_static/custom.css +233 -0
  8. pytgflow-1.0.0/docs/_static/logo.png +0 -0
  9. pytgflow-1.0.0/docs/_static/scroll_indicator.js +89 -0
  10. pytgflow-1.0.0/docs/advanced_features.rst +134 -0
  11. pytgflow-1.0.0/docs/api.rst +113 -0
  12. pytgflow-1.0.0/docs/auth.rst +134 -0
  13. pytgflow-1.0.0/docs/calls.rst +226 -0
  14. pytgflow-1.0.0/docs/changelog.rst +99 -0
  15. pytgflow-1.0.0/docs/conf.py +38 -0
  16. pytgflow-1.0.0/docs/filters.rst +157 -0
  17. pytgflow-1.0.0/docs/formatting.rst +64 -0
  18. pytgflow-1.0.0/docs/index.rst +40 -0
  19. pytgflow-1.0.0/docs/keyboards.rst +145 -0
  20. pytgflow-1.0.0/docs/methods.rst +270 -0
  21. pytgflow-1.0.0/docs/mtproto.rst +63 -0
  22. pytgflow-1.0.0/docs/quickstart.rst +92 -0
  23. pytgflow-1.0.0/docs/raw_namespaces.rst +171 -0
  24. pytgflow-1.0.0/docs/sessions.rst +39 -0
  25. pytgflow-1.0.0/docs.sh +6 -0
  26. pytgflow-1.0.0/examples/echo_bot.py +35 -0
  27. pytgflow-1.0.0/examples/group_calls_webrtc.py +41 -0
  28. pytgflow-1.0.0/examples/moderation_bot.py +52 -0
  29. pytgflow-1.0.0/examples/userbot_mtproto.py +47 -0
  30. pytgflow-1.0.0/publish.sh +22 -0
  31. pytgflow-1.0.0/pyproject.toml +55 -0
  32. pytgflow-1.0.0/pytgflow.egg-info/PKG-INFO +175 -0
  33. pytgflow-1.0.0/pytgflow.egg-info/SOURCES.txt +161 -0
  34. pytgflow-1.0.0/pytgflow.egg-info/dependency_links.txt +1 -0
  35. pytgflow-1.0.0/pytgflow.egg-info/requires.txt +11 -0
  36. pytgflow-1.0.0/pytgflow.egg-info/top_level.txt +1 -0
  37. pytgflow-1.0.0/requirements-dev.txt +9 -0
  38. pytgflow-1.0.0/requirements.txt +1 -0
  39. pytgflow-1.0.0/schema_official.tl +2976 -0
  40. pytgflow-1.0.0/setup.cfg +4 -0
  41. pytgflow-1.0.0/setup.py +62 -0
  42. pytgflow-1.0.0/test.sh +5 -0
  43. pytgflow-1.0.0/tests/test_auth_and_methods.py +89 -0
  44. pytgflow-1.0.0/tests/test_client.py +85 -0
  45. pytgflow-1.0.0/tests/test_client_methods_browser.py +80 -0
  46. pytgflow-1.0.0/tests/test_command_formats.py +168 -0
  47. pytgflow-1.0.0/tests/test_crypto.py +46 -0
  48. pytgflow-1.0.0/tests/test_errors_and_rich.py +87 -0
  49. pytgflow-1.0.0/tests/test_filters.py +44 -0
  50. pytgflow-1.0.0/tests/test_flow_markup.py +96 -0
  51. pytgflow-1.0.0/tests/test_formatting.py +52 -0
  52. pytgflow-1.0.0/tests/test_group_calls.py +112 -0
  53. pytgflow-1.0.0/tests/test_namespaces_and_mtproto_schema.py +144 -0
  54. pytgflow-1.0.0/tests/test_official_schema.py +71 -0
  55. pytgflow-1.0.0/tests/test_session.py +29 -0
  56. pytgflow-1.0.0/tests/test_tl.py +44 -0
  57. pytgflow-1.0.0/tgflow/__init__.py +201 -0
  58. pytgflow-1.0.0/tgflow/client.py +1648 -0
  59. pytgflow-1.0.0/tgflow/crypto/__init__.py +13 -0
  60. pytgflow-1.0.0/tgflow/crypto/aes_ige.py +37 -0
  61. pytgflow-1.0.0/tgflow/crypto/diffie_hellman.py +26 -0
  62. pytgflow-1.0.0/tgflow/crypto/factorization.py +24 -0
  63. pytgflow-1.0.0/tgflow/crypto/obfuscated2.py +36 -0
  64. pytgflow-1.0.0/tgflow/errors.py +299 -0
  65. pytgflow-1.0.0/tgflow/filters.py +427 -0
  66. pytgflow-1.0.0/tgflow/formatting.py +396 -0
  67. pytgflow-1.0.0/tgflow/py.typed +1 -0
  68. pytgflow-1.0.0/tgflow/raw/__init__.py +10 -0
  69. pytgflow-1.0.0/tgflow/raw/functions/__init__.py +53 -0
  70. pytgflow-1.0.0/tgflow/raw/functions/account.py +498 -0
  71. pytgflow-1.0.0/tgflow/raw/functions/aicompose.py +34 -0
  72. pytgflow-1.0.0/tgflow/raw/functions/auth.py +110 -0
  73. pytgflow-1.0.0/tgflow/raw/functions/bots.py +154 -0
  74. pytgflow-1.0.0/tgflow/raw/functions/channels.py +238 -0
  75. pytgflow-1.0.0/tgflow/raw/functions/chatlists.py +50 -0
  76. pytgflow-1.0.0/tgflow/raw/functions/contacts.py +118 -0
  77. pytgflow-1.0.0/tgflow/raw/functions/folders.py +10 -0
  78. pytgflow-1.0.0/tgflow/raw/functions/fragment.py +10 -0
  79. pytgflow-1.0.0/tgflow/raw/functions/help.py +106 -0
  80. pytgflow-1.0.0/tgflow/raw/functions/langpack.py +26 -0
  81. pytgflow-1.0.0/tgflow/raw/functions/messages.py +1026 -0
  82. pytgflow-1.0.0/tgflow/raw/functions/payments.py +266 -0
  83. pytgflow-1.0.0/tgflow/raw/functions/phone.py +178 -0
  84. pytgflow-1.0.0/tgflow/raw/functions/photos.py +26 -0
  85. pytgflow-1.0.0/tgflow/raw/functions/premium.py +26 -0
  86. pytgflow-1.0.0/tgflow/raw/functions/root.py +28 -0
  87. pytgflow-1.0.0/tgflow/raw/functions/smsjobs.py +34 -0
  88. pytgflow-1.0.0/tgflow/raw/functions/stats.py +38 -0
  89. pytgflow-1.0.0/tgflow/raw/functions/stickers.py +50 -0
  90. pytgflow-1.0.0/tgflow/raw/functions/stories.py +138 -0
  91. pytgflow-1.0.0/tgflow/raw/functions/updates.py +18 -0
  92. pytgflow-1.0.0/tgflow/raw/functions/upload.py +38 -0
  93. pytgflow-1.0.0/tgflow/raw/functions/users.py +34 -0
  94. pytgflow-1.0.0/tgflow/raw/types/__init__.py +49 -0
  95. pytgflow-1.0.0/tgflow/raw/types/account.py +158 -0
  96. pytgflow-1.0.0/tgflow/raw/types/aicompose.py +14 -0
  97. pytgflow-1.0.0/tgflow/raw/types/auth.py +118 -0
  98. pytgflow-1.0.0/tgflow/raw/types/bots.py +30 -0
  99. pytgflow-1.0.0/tgflow/raw/types/channels.py +38 -0
  100. pytgflow-1.0.0/tgflow/raw/types/chatlists.py +26 -0
  101. pytgflow-1.0.0/tgflow/raw/types/contacts.py +58 -0
  102. pytgflow-1.0.0/tgflow/raw/types/fragment.py +10 -0
  103. pytgflow-1.0.0/tgflow/raw/types/help.py +130 -0
  104. pytgflow-1.0.0/tgflow/raw/types/messages.py +374 -0
  105. pytgflow-1.0.0/tgflow/raw/types/payments.py +154 -0
  106. pytgflow-1.0.0/tgflow/raw/types/phone.py +38 -0
  107. pytgflow-1.0.0/tgflow/raw/types/photos.py +18 -0
  108. pytgflow-1.0.0/tgflow/raw/types/premium.py +18 -0
  109. pytgflow-1.0.0/tgflow/raw/types/smsjobs.py +14 -0
  110. pytgflow-1.0.0/tgflow/raw/types/stats.py +30 -0
  111. pytgflow-1.0.0/tgflow/raw/types/stickers.py +10 -0
  112. pytgflow-1.0.0/tgflow/raw/types/storage.py +46 -0
  113. pytgflow-1.0.0/tgflow/raw/types/stories.py +50 -0
  114. pytgflow-1.0.0/tgflow/raw/types/updates.py +38 -0
  115. pytgflow-1.0.0/tgflow/raw/types/upload.py +26 -0
  116. pytgflow-1.0.0/tgflow/raw/types/users.py +26 -0
  117. pytgflow-1.0.0/tgflow/rich.py +141 -0
  118. pytgflow-1.0.0/tgflow/rpc/__init__.py +7 -0
  119. pytgflow-1.0.0/tgflow/rpc/message_id.py +18 -0
  120. pytgflow-1.0.0/tgflow/rpc/packet.py +75 -0
  121. pytgflow-1.0.0/tgflow/session.py +120 -0
  122. pytgflow-1.0.0/tgflow/tl/__init__.py +14 -0
  123. pytgflow-1.0.0/tgflow/tl/core.py +176 -0
  124. pytgflow-1.0.0/tgflow/tl/functions/__init__.py +761 -0
  125. pytgflow-1.0.0/tgflow/tl/functions/compat.py +2087 -0
  126. pytgflow-1.0.0/tgflow/tl/functions/handshake.py +128 -0
  127. pytgflow-1.0.0/tgflow/tl/functions/mtproto.py +179 -0
  128. pytgflow-1.0.0/tgflow/tl/functions/part1.py +3528 -0
  129. pytgflow-1.0.0/tgflow/tl/functions/part2.py +3429 -0
  130. pytgflow-1.0.0/tgflow/tl/functions/part3.py +3450 -0
  131. pytgflow-1.0.0/tgflow/tl/functions/part4.py +3508 -0
  132. pytgflow-1.0.0/tgflow/tl/functions/part5.py +3468 -0
  133. pytgflow-1.0.0/tgflow/tl/functions/part6.py +1627 -0
  134. pytgflow-1.0.0/tgflow/tl/types/__init__.py +344 -0
  135. pytgflow-1.0.0/tgflow/tl/types/end_to_end.py +2055 -0
  136. pytgflow-1.0.0/tgflow/tl/types/handshake.py +328 -0
  137. pytgflow-1.0.0/tgflow/tl/types/mtproto.py +878 -0
  138. pytgflow-1.0.0/tgflow/tl/types/part1.py +3196 -0
  139. pytgflow-1.0.0/tgflow/tl/types/part10.py +3438 -0
  140. pytgflow-1.0.0/tgflow/tl/types/part11.py +3442 -0
  141. pytgflow-1.0.0/tgflow/tl/types/part12.py +3425 -0
  142. pytgflow-1.0.0/tgflow/tl/types/part13.py +1055 -0
  143. pytgflow-1.0.0/tgflow/tl/types/part2.py +3417 -0
  144. pytgflow-1.0.0/tgflow/tl/types/part3.py +3464 -0
  145. pytgflow-1.0.0/tgflow/tl/types/part4.py +3453 -0
  146. pytgflow-1.0.0/tgflow/tl/types/part5.py +3498 -0
  147. pytgflow-1.0.0/tgflow/tl/types/part6.py +3463 -0
  148. pytgflow-1.0.0/tgflow/tl/types/part7.py +3496 -0
  149. pytgflow-1.0.0/tgflow/tl/types/part8.py +3471 -0
  150. pytgflow-1.0.0/tgflow/tl/types/part9.py +3439 -0
  151. pytgflow-1.0.0/tgflow/transport/__init__.py +5 -0
  152. pytgflow-1.0.0/tgflow/transport/tcp.py +62 -0
  153. pytgflow-1.0.0/tgflow/types/__init__.py +84 -0
  154. pytgflow-1.0.0/tgflow/types/chat.py +36 -0
  155. pytgflow-1.0.0/tgflow/types/chat_member.py +100 -0
  156. pytgflow-1.0.0/tgflow/types/features.py +75 -0
  157. pytgflow-1.0.0/tgflow/types/group_call.py +50 -0
  158. pytgflow-1.0.0/tgflow/types/keyboards.py +290 -0
  159. pytgflow-1.0.0/tgflow/types/media.py +195 -0
  160. pytgflow-1.0.0/tgflow/types/message.py +189 -0
  161. pytgflow-1.0.0/tgflow/types/polls.py +41 -0
  162. pytgflow-1.0.0/tgflow/types/updates.py +94 -0
  163. pytgflow-1.0.0/tgflow/types/user.py +45 -0
@@ -0,0 +1,67 @@
1
+ # Changelog & Release Notes
2
+
3
+ All notable changes and architectural milestones of **TgFlow** are documented here.
4
+
5
+ ## [1.7.0] - 2026-10-24
6
+
7
+ ### Complete Telegram Browser & MTProto 2.0 Integration
8
+ - **Official MTProto Core Schema**: Integrated all 45 types and 9 core RPC functions from `core.telegram.org/schema/mtproto` (`ReqPqMulti`, `ReqDHParams`, `SetClientDHParams`, `RpcDropAnswer`, `GetFutureSalts`, `Ping`, `PingDelayDisconnect`, `DestroySession`, `DestroyAuthKey`).
9
+ - **Secret Chats End-to-End Encryption**: Added all 90 constructors from `core.telegram.org/schema/end-to-end` in `tgflow.tl.types.end_to_end`.
10
+ - **24 Raw Namespaces in `tgflow.raw`**: Dedicated namespace modules for `account`, `aicompose`, `auth`, `bots`, `channels`, `chatlists`, `contacts`, `folders`, `fragment`, `help`, `langpack`, `messages`, `payments`, `phone`, `photos`, `premium`, `smsjobs`, `stats`, `stickers`, `stories`, `updates`, `upload`, `users`, and `root`.
11
+ - **Advanced Client Operations**: Added 25+ high-level methods on `TgFlow` for Stories, Telegram Stars, Star gifts, Fragment collectibles, Bot menu buttons, Mini apps, and SMS Gateway verification jobs.
12
+ - **Full Test Coverage**: Expanded automated unit test suite to 59 tests covering all namespaces and client methods.
13
+
14
+ ## [1.6.0] - 2026-10-24
15
+
16
+ ### Official Layer 225 Schema Compilation & Animated Scroll UI
17
+ - **Complete Layer 225 Coverage**: Compiled 100% of `core.telegram.org/schema` (1,573 TL types and 783 RPC functions).
18
+ - **Modular Code Partitioning**: Partitioned types (13 parts) and functions (6 parts) ensuring all files remain clean and manageable.
19
+ - **Animated Scroll Rail**: Added smooth animated vertical scroll tracking rail and TOC scrollspy indicator matching modern documentation UX.
20
+ - **Dice Reel Scrolling Animation**: Full support for `inputMediaDice` and `messageMediaDice` with slot machine animated scroll simulation.
21
+ - **Zero Comment Enforcement**: Core library verified with zero comment clutter across all Python files.
22
+
23
+ ## [1.5.0] - 2026-10-24
24
+
25
+ ### RPC Error Hierarchy, Rich Text & AI Assistant
26
+ - **Typed RPC Error Hierarchy**: Added 130+ granular exception classes mapped directly to MTProto 400, 401, 403, 406, 420, and 500 error strings.
27
+ - **FloodWait Precision**: Automatic extraction of penalty duration into `e.seconds`.
28
+ - **Fluent RichText Builder**: Chainable DSL for composing bold, italic, code, underline, strikethrough, spoiler, custom animated emoji, and expandable blockquote entities.
29
+ - **AIComposer Tool**: Structured text drafting and summarization helper with native translation RPC integration.
30
+ - **Ephemeral Message Timers**: High-level `send_ephemeral()` and `set_chat_ttl()` methods.
31
+
32
+ ## [1.4.0] - 2026-10-24
33
+
34
+ ### Group & Channel Administration Suite & FlowMarkup DSL
35
+ - **FlowMarkup DSL**: Fluent inline keyboard builder supporting text, callback, url, web app, switch inline, and copy text buttons.
36
+ - **Forum Topics**: Full support for creating, editing, closing, reopening, and deleting forum topic history.
37
+ - **Member Moderation**: Added `ban_chat_member`, `unban_chat_member`, `restrict_chat_member`, and `promote_chat_member`.
38
+ - **Dialog & Message History**: Added `search_messages`, `get_history`, and `get_dialogs`.
39
+
40
+ ## [1.3.0] - 2026-10-24
41
+
42
+ ### VoIP & Group Call Coordination (py-tgcalls / ntgcalls)
43
+ - **Phone RPC Calls**: Native support for `phone.requestCall`, `phone.acceptCall`, `phone.confirmCall`, and `phone.discardCall`.
44
+ - **Group Calls & Live Streams**: Added `create_group_call`, `join_group_call`, `leave_group_call`, and `edit_group_call_participant`.
45
+ - **WebRTC & VoIP Compatibility**: Full protocol negotiation support matching `py-tgcalls` and `ntgcalls` requirements.
46
+
47
+ ## [1.2.0] - 2026-10-23
48
+
49
+ ### Formatting DSL & Message Entities
50
+ - **HTML Entity Parser**: Fast entity parser supporting `<b>`, `<i>`, `<code>`, `<pre>`, `<s>`, `<u>`, `<spoiler>`, `<blockquote>`, and `<tg-emoji>`.
51
+ - **Collapsible Blockquotes**: Expandable quote support for Layer 180+.
52
+ - **Custom Animated Emoji**: Support for Telegram Premium custom animated emoji entities.
53
+
54
+ ## [1.1.0] - 2026-10-23
55
+
56
+ ### High-Level Client API & Declarative Routing
57
+ - **Decorator Routing**: Added `@client.on_message()`, `@client.command()`, and `@client.on_callback_query()`.
58
+ - **Composable Filters**: Declarative filter combinators supporting `&` (AND), `|` (OR), and `~` (NOT).
59
+ - **Portable Sessions**: Base64 session string export and import with CRC32 checksums.
60
+
61
+ ## [1.0.0] - 2026-10-23
62
+
63
+ ### Initial Release: Pure Python MTProto 2.0 Engine
64
+ - **Obfuscated2 Framing**: 64-byte randomized header generation avoiding protocol fingerprinting.
65
+ - **AES-256 IGE Encryption**: Pure Python symmetric encryption for encrypted data transport.
66
+ - **Diffie-Hellman Key Derivation**: Sub-millisecond Pollard's rho prime factorization and 2048-bit DH key exchange.
67
+ - **Binary Serialization**: Fast 4-byte aligned TL reader and writer.
pytgflow-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VeezNetworks & TgFlow Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include pyproject.toml
5
+ include setup.py
6
+ include requirements.txt
7
+ include requirements-dev.txt
8
+ include *.sh
9
+ include schema_official.tl
10
+ include tgflow/py.typed
11
+ recursive-include docs *.rst *.py *.css *.js *.png *.svg
12
+ recursive-include examples *.py
13
+ prune docs/_build
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytgflow
3
+ Version: 1.0.0
4
+ Summary: Pure Python MTProto 2.0 Telegram framework engineered for speed, clean architecture, and modern bot development
5
+ Home-page: https://github.com/VeezNetworks/TgFlow
6
+ Author: VeezNetworks
7
+ Author-email: contact@veez.net
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/VeezNetworks/TgFlow
10
+ Project-URL: Documentation, https://tgflow.veez.dev
11
+ Project-URL: Repository, https://github.com/VeezNetworks/TgFlow.git
12
+ Project-URL: Issues, https://github.com/VeezNetworks/TgFlow/issues
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Communications :: Chat
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: cryptography>=41.0.0
28
+ Provides-Extra: docs
29
+ Requires-Dist: sphinx>=7.0.0; extra == "docs"
30
+ Requires-Dist: furo>=2024.1.29; extra == "docs"
31
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
32
+ Requires-Dist: sphinx-inline-tabs>=2023.4.21; extra == "docs"
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest>=7.0.0; extra == "test"
35
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
36
+ Dynamic: author-email
37
+ Dynamic: home-page
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+
41
+ <div align="center">
42
+ <img src="assets/logo.png" alt="TgFlow Logo" width="180"/>
43
+ <h1>TgFlow</h1>
44
+ <p><b>Pure Python MTProto 2.0 Telegram Framework</b></p>
45
+ <p>Engineered for speed, intuitive routing typography, full Telegram Layer 225 schema, 24 raw namespaces, and zero comment clutter.</p>
46
+ </div>
47
+
48
+ ---
49
+
50
+ ## Highlights
51
+
52
+ - **Pure MTProto 2.0 Engine**: Built from scratch adhering strictly to official Telegram MTProto specifications.
53
+ - **Complete Official Schema (Layer 225)**: Exactly 1,573 TL types and 783 RPC methods compiled into type-safe Python classes with exact 4-byte aligned serialization.
54
+ - **24 Raw Namespaces**: Direct low-level access via `tgflow.raw.functions.<namespace>` and `tgflow.raw.types.<namespace>` (`messages`, `channels`, `phone`, `payments`, `stories`, `aicompose`, `smsjobs`, etc.).
55
+ - **MTProto Core & E2E Secret Chats**: Native implementations of `core.telegram.org/schema/mtproto` (45 types, 9 functions) and `core.telegram.org/schema/end-to-end` (90 constructors).
56
+ - **Obfuscated2 TCP Framing**: Live-verified transport connection to Telegram DC2 with 64-byte random payload handshakes.
57
+ - **Advanced Routing Typography**: Replaces cumbersome filter syntax with concise, direct decorators:
58
+ - `@bot.command("start")`
59
+ - `@bot.callback("confirm")`
60
+ - `@bot.message(When.photo)`
61
+ - `@bot.inline()`
62
+ - **Expressive When Condition Engine**: Intuitive condition combinators via `When` (or `F`): `When.photo | When.video`, `When.private & ~When.bot`.
63
+ - **Comprehensive Telegram Client API**: Over 110 client methods covering media sending, polls, chat management, forum topics, stories, stars, collectibles, reactions, and VoIP/group calls.
64
+ - **Rich Telegram Formatting**: Full support for expandable blockquotes, spoilers, custom emoji, clickable links, and copy-text buttons.
65
+ - **Interactive Documentation**: Sphinx documentation featuring a dynamic animated scroll rail and TOC scrollspy.
66
+ - **Zero Comments In Core Code**: Self-explanatory, line-by-line clean idiomatic Python.
67
+
68
+ ---
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install pytgflow
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Quickstart
79
+
80
+ ```python
81
+ import asyncio
82
+ from tgflow import TgFlow, When, CommandContext
83
+ from tgflow.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
84
+
85
+ bot = TgFlow(
86
+ session="my_bot",
87
+ bot_token="YOUR_BOT_TOKEN_HERE",
88
+ )
89
+
90
+ # 1. Zero-argument command decorator (inferred from function name)
91
+ @bot.command
92
+ async def ping(client: TgFlow, message: Message):
93
+ await message.reply("pong!")
94
+
95
+ # 2. Typed parameterized command with automatic argument injection
96
+ @bot.command("ban <user_id:int> [reason:str]")
97
+ async def ban_user(client: TgFlow, message: Message, user_id: int, reason: str = "Spam"):
98
+ await client.ban_chat_member(message.chat.id, user_id)
99
+ await message.reply(f"Banned user {user_id}. Reason: {reason}")
100
+
101
+ # 3. CommandContext (ctx) shortcut
102
+ @bot.command("start", when=When.private)
103
+ async def handle_start(ctx: CommandContext):
104
+ keyboard = InlineKeyboardMarkup([
105
+ [InlineKeyboardButton(text="GitHub", url="https://github.com/VeezNetworks/TgFlow")],
106
+ [InlineKeyboardButton(text="Verify", callback_data="verify_user")]
107
+ ])
108
+ await ctx.reply(
109
+ "<b>Welcome to TgFlow!</b>\n\nExperience clean, modern MTProto 2.0 in Python.",
110
+ parse_mode="html",
111
+ reply_markup=keyboard,
112
+ )
113
+
114
+ @bot.callback("verify_user")
115
+ async def handle_callback(client: TgFlow, query):
116
+ await query.answer("Account verified!", show_alert=True)
117
+
118
+ @bot.command("quote")
119
+ async def handle_quote(client: TgFlow, message: Message):
120
+ await message.reply_quote(
121
+ text="Native MTProto quote reply.",
122
+ quote=message.text,
123
+ )
124
+
125
+ @bot.command("secret")
126
+ async def handle_secret(client: TgFlow, message: Message):
127
+ await message.reply_ephemeral(
128
+ text="This message will self-destruct in 10 seconds.",
129
+ ttl_seconds=10,
130
+ )
131
+
132
+ asyncio.run(bot.run())
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Comprehensive Architecture
138
+
139
+ | Domain | Module | Highlights |
140
+ |---|---|---|
141
+ | **Client & Methods** | `tgflow.client` | 110+ methods: send media, stories, stars, gifts, forum topics, group calls |
142
+ | **Raw Namespaces** | `tgflow.raw` | 24 namespaces: `messages`, `channels`, `phone`, `payments`, `stories`, `aicompose`, etc. |
143
+ | **Typography & Routing** | `tgflow.filters` | Direct decorators `@bot.command`, `@bot.callback`, `When` & `F` engine |
144
+ | **Rich Types** | `tgflow.types` | `Message`, `User`, `Chat`, `Photo`, `Poll`, `InlineKeyboardMarkup`, `ChatMember` |
145
+ | **MTProto Transport** | `tgflow.transport` | Obfuscated2 framing, intermediate protocol (`0xeeeeeeee`) |
146
+ | **Crypto & Handshake** | `tgflow.crypto` | AES-256 IGE, Pollard's rho PQ factorization, DH key exchange |
147
+ | **Binary TL Schema** | `tgflow.tl` | `TLReader`/`TLWriter`, 2,356 constructors, 4-byte aligned serialization |
148
+ | **Sessions** | `tgflow.session` | Portable string sessions with CRC32 integrity verification |
149
+
150
+ ---
151
+
152
+ ## Documentation
153
+
154
+ Interactive documentation is built using Sphinx with the Furo UI and custom animated scroll tracking:
155
+
156
+ ```bash
157
+ sphinx-build -b html docs docs/_build/html
158
+ ```
159
+
160
+ Preview locally:
161
+ ```bash
162
+ python -m http.server 8000 --directory docs/_build/html
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Changelog
168
+
169
+ See [CHANGELOG.md](CHANGELOG.md) for full release notes and version history.
170
+
171
+ ---
172
+
173
+ ## License
174
+
175
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,135 @@
1
+ <div align="center">
2
+ <img src="assets/logo.png" alt="TgFlow Logo" width="180"/>
3
+ <h1>TgFlow</h1>
4
+ <p><b>Pure Python MTProto 2.0 Telegram Framework</b></p>
5
+ <p>Engineered for speed, intuitive routing typography, full Telegram Layer 225 schema, 24 raw namespaces, and zero comment clutter.</p>
6
+ </div>
7
+
8
+ ---
9
+
10
+ ## Highlights
11
+
12
+ - **Pure MTProto 2.0 Engine**: Built from scratch adhering strictly to official Telegram MTProto specifications.
13
+ - **Complete Official Schema (Layer 225)**: Exactly 1,573 TL types and 783 RPC methods compiled into type-safe Python classes with exact 4-byte aligned serialization.
14
+ - **24 Raw Namespaces**: Direct low-level access via `tgflow.raw.functions.<namespace>` and `tgflow.raw.types.<namespace>` (`messages`, `channels`, `phone`, `payments`, `stories`, `aicompose`, `smsjobs`, etc.).
15
+ - **MTProto Core & E2E Secret Chats**: Native implementations of `core.telegram.org/schema/mtproto` (45 types, 9 functions) and `core.telegram.org/schema/end-to-end` (90 constructors).
16
+ - **Obfuscated2 TCP Framing**: Live-verified transport connection to Telegram DC2 with 64-byte random payload handshakes.
17
+ - **Advanced Routing Typography**: Replaces cumbersome filter syntax with concise, direct decorators:
18
+ - `@bot.command("start")`
19
+ - `@bot.callback("confirm")`
20
+ - `@bot.message(When.photo)`
21
+ - `@bot.inline()`
22
+ - **Expressive When Condition Engine**: Intuitive condition combinators via `When` (or `F`): `When.photo | When.video`, `When.private & ~When.bot`.
23
+ - **Comprehensive Telegram Client API**: Over 110 client methods covering media sending, polls, chat management, forum topics, stories, stars, collectibles, reactions, and VoIP/group calls.
24
+ - **Rich Telegram Formatting**: Full support for expandable blockquotes, spoilers, custom emoji, clickable links, and copy-text buttons.
25
+ - **Interactive Documentation**: Sphinx documentation featuring a dynamic animated scroll rail and TOC scrollspy.
26
+ - **Zero Comments In Core Code**: Self-explanatory, line-by-line clean idiomatic Python.
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install pytgflow
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ import asyncio
42
+ from tgflow import TgFlow, When, CommandContext
43
+ from tgflow.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
44
+
45
+ bot = TgFlow(
46
+ session="my_bot",
47
+ bot_token="YOUR_BOT_TOKEN_HERE",
48
+ )
49
+
50
+ # 1. Zero-argument command decorator (inferred from function name)
51
+ @bot.command
52
+ async def ping(client: TgFlow, message: Message):
53
+ await message.reply("pong!")
54
+
55
+ # 2. Typed parameterized command with automatic argument injection
56
+ @bot.command("ban <user_id:int> [reason:str]")
57
+ async def ban_user(client: TgFlow, message: Message, user_id: int, reason: str = "Spam"):
58
+ await client.ban_chat_member(message.chat.id, user_id)
59
+ await message.reply(f"Banned user {user_id}. Reason: {reason}")
60
+
61
+ # 3. CommandContext (ctx) shortcut
62
+ @bot.command("start", when=When.private)
63
+ async def handle_start(ctx: CommandContext):
64
+ keyboard = InlineKeyboardMarkup([
65
+ [InlineKeyboardButton(text="GitHub", url="https://github.com/VeezNetworks/TgFlow")],
66
+ [InlineKeyboardButton(text="Verify", callback_data="verify_user")]
67
+ ])
68
+ await ctx.reply(
69
+ "<b>Welcome to TgFlow!</b>\n\nExperience clean, modern MTProto 2.0 in Python.",
70
+ parse_mode="html",
71
+ reply_markup=keyboard,
72
+ )
73
+
74
+ @bot.callback("verify_user")
75
+ async def handle_callback(client: TgFlow, query):
76
+ await query.answer("Account verified!", show_alert=True)
77
+
78
+ @bot.command("quote")
79
+ async def handle_quote(client: TgFlow, message: Message):
80
+ await message.reply_quote(
81
+ text="Native MTProto quote reply.",
82
+ quote=message.text,
83
+ )
84
+
85
+ @bot.command("secret")
86
+ async def handle_secret(client: TgFlow, message: Message):
87
+ await message.reply_ephemeral(
88
+ text="This message will self-destruct in 10 seconds.",
89
+ ttl_seconds=10,
90
+ )
91
+
92
+ asyncio.run(bot.run())
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Comprehensive Architecture
98
+
99
+ | Domain | Module | Highlights |
100
+ |---|---|---|
101
+ | **Client & Methods** | `tgflow.client` | 110+ methods: send media, stories, stars, gifts, forum topics, group calls |
102
+ | **Raw Namespaces** | `tgflow.raw` | 24 namespaces: `messages`, `channels`, `phone`, `payments`, `stories`, `aicompose`, etc. |
103
+ | **Typography & Routing** | `tgflow.filters` | Direct decorators `@bot.command`, `@bot.callback`, `When` & `F` engine |
104
+ | **Rich Types** | `tgflow.types` | `Message`, `User`, `Chat`, `Photo`, `Poll`, `InlineKeyboardMarkup`, `ChatMember` |
105
+ | **MTProto Transport** | `tgflow.transport` | Obfuscated2 framing, intermediate protocol (`0xeeeeeeee`) |
106
+ | **Crypto & Handshake** | `tgflow.crypto` | AES-256 IGE, Pollard's rho PQ factorization, DH key exchange |
107
+ | **Binary TL Schema** | `tgflow.tl` | `TLReader`/`TLWriter`, 2,356 constructors, 4-byte aligned serialization |
108
+ | **Sessions** | `tgflow.session` | Portable string sessions with CRC32 integrity verification |
109
+
110
+ ---
111
+
112
+ ## Documentation
113
+
114
+ Interactive documentation is built using Sphinx with the Furo UI and custom animated scroll tracking:
115
+
116
+ ```bash
117
+ sphinx-build -b html docs docs/_build/html
118
+ ```
119
+
120
+ Preview locally:
121
+ ```bash
122
+ python -m http.server 8000 --directory docs/_build/html
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Changelog
128
+
129
+ See [CHANGELOG.md](CHANGELOG.md) for full release notes and version history.
130
+
131
+ ---
132
+
133
+ ## License
134
+
135
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "==> Cleaning old build artifacts..."
5
+ rm -rf build/ dist/ *.egg-info
6
+
7
+ echo "==> Running test suite..."
8
+ python -m unittest discover tests
9
+
10
+ echo "==> Building distribution packages (wheel and sdist)..."
11
+ python -m build
12
+
13
+ echo "==> Verifying distribution packages with twine..."
14
+ twine check dist/*
15
+
16
+ echo "==> Build completed successfully!"
@@ -0,0 +1,233 @@
1
+ :root {
2
+ --font-stack: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
3
+ --font-stack--monospace: "JetBrains Mono", "Fira Code", Consolas, Monaco, "Courier New", monospace;
4
+ --tg-blue-light: #0088cc;
5
+ --tg-blue-dark: #24a1de;
6
+ --tg-gradient: linear-gradient(135deg, #0088cc 0%, #00b4d8 100%);
7
+ }
8
+
9
+ body {
10
+ font-family: var(--font-stack);
11
+ letter-spacing: -0.011em;
12
+ -webkit-font-smoothing: antialiased;
13
+ }
14
+
15
+ code, kbd, samp, pre {
16
+ font-family: var(--font-stack--monospace) !important;
17
+ }
18
+
19
+ h1 {
20
+ font-weight: 800;
21
+ letter-spacing: -0.03em;
22
+ background: linear-gradient(135deg, #0088cc 0%, #0077b6 100%);
23
+ -webkit-background-clip: text;
24
+ -webkit-text-fill-color: transparent;
25
+ display: inline-block;
26
+ margin-bottom: 0.8rem;
27
+ }
28
+
29
+ h2 {
30
+ font-weight: 700;
31
+ letter-spacing: -0.02em;
32
+ margin-top: 2rem;
33
+ border-bottom: 2px solid rgba(0, 136, 204, 0.15);
34
+ padding-bottom: 0.35rem;
35
+ }
36
+
37
+ h3 {
38
+ font-weight: 600;
39
+ letter-spacing: -0.015em;
40
+ margin-top: 1.5rem;
41
+ }
42
+
43
+ .highlight {
44
+ border-radius: 10px;
45
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
46
+ border: 1px solid rgba(0, 0, 0, 0.08);
47
+ }
48
+
49
+ html[data-theme="dark"] .highlight {
50
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
51
+ border: 1px solid rgba(255, 255, 255, 0.08);
52
+ }
53
+
54
+ .admonition {
55
+ border-radius: 8px;
56
+ border-left-width: 4px !important;
57
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
58
+ }
59
+
60
+ .admonition.note {
61
+ border-left-color: #0088cc !important;
62
+ }
63
+
64
+ .admonition.tip {
65
+ border-left-color: #10b981 !important;
66
+ }
67
+
68
+ .admonition.warning {
69
+ border-left-color: #f59e0b !important;
70
+ }
71
+
72
+ table.docutils {
73
+ border-radius: 8px;
74
+ overflow: hidden;
75
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
76
+ border: 1px solid rgba(0, 0, 0, 0.08);
77
+ border-collapse: separate;
78
+ border-spacing: 0;
79
+ width: 100%;
80
+ margin: 1.5rem 0;
81
+ }
82
+
83
+ table.docutils thead th {
84
+ background: rgba(0, 136, 204, 0.08);
85
+ font-weight: 600;
86
+ border-bottom: 2px solid rgba(0, 136, 204, 0.2);
87
+ padding: 10px 14px;
88
+ }
89
+
90
+ table.docutils td {
91
+ padding: 10px 14px;
92
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
93
+ }
94
+
95
+ html[data-theme="dark"] table.docutils td {
96
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
97
+ }
98
+
99
+ table.docutils tr:last-child td {
100
+ border-bottom: none;
101
+ }
102
+
103
+ .sidebar-brand-text {
104
+ font-weight: 800;
105
+ letter-spacing: -0.02em;
106
+ }
107
+
108
+ .sig-name {
109
+ color: #0088cc !important;
110
+ font-weight: 700;
111
+ }
112
+
113
+ html[data-theme="dark"] .sig-name {
114
+ color: #24a1de !important;
115
+ }
116
+
117
+ .sig-paren {
118
+ opacity: 0.7;
119
+ }
120
+
121
+ .sidebar-drawer {
122
+ box-shadow: 1px 0 10px rgba(0, 0, 0, 0.03);
123
+ }
124
+
125
+ ::-webkit-scrollbar {
126
+ width: 7px;
127
+ height: 7px;
128
+ }
129
+
130
+ ::-webkit-scrollbar-track {
131
+ background: transparent;
132
+ }
133
+
134
+ ::-webkit-scrollbar-thumb {
135
+ background: rgba(0, 136, 204, 0.25);
136
+ border-radius: 4px;
137
+ }
138
+
139
+ ::-webkit-scrollbar-thumb:hover {
140
+ background: rgba(0, 136, 204, 0.5);
141
+ }
142
+ html {
143
+ scroll-behavior: smooth;
144
+ }
145
+
146
+ .toc-tree a {
147
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
148
+ border-left: 2.5px solid transparent;
149
+ padding-left: 6px;
150
+ display: block;
151
+ }
152
+
153
+ .toc-tree a:hover {
154
+ color: #0088cc !important;
155
+ transform: translateX(3px);
156
+ }
157
+
158
+ .toc-tree a.tgflow-toc-active {
159
+ color: #0088cc !important;
160
+ font-weight: 600;
161
+ border-left: 2.5px solid #0088cc !important;
162
+ background: rgba(0, 136, 204, 0.08);
163
+ border-radius: 0 4px 4px 0;
164
+ transform: translateX(4px);
165
+ }
166
+
167
+ html[data-theme="dark"] .toc-tree a.tgflow-toc-active {
168
+ color: #24a1de !important;
169
+ border-left-color: #24a1de !important;
170
+ background: rgba(36, 161, 222, 0.12);
171
+ }
172
+
173
+ .tgflow-scroll-rail {
174
+ position: fixed;
175
+ right: 8px;
176
+ top: 90px;
177
+ bottom: 90px;
178
+ width: 14px;
179
+ z-index: 999;
180
+ display: flex;
181
+ justify-content: flex-end;
182
+ pointer-events: none;
183
+ }
184
+
185
+ @media (max-width: 1024px) {
186
+ .tgflow-scroll-rail {
187
+ display: none;
188
+ }
189
+ }
190
+
191
+ .tgflow-scroll-track {
192
+ position: relative;
193
+ width: 10px;
194
+ height: 100%;
195
+ border-right: 2px solid rgba(0, 0, 0, 0.15);
196
+ cursor: pointer;
197
+ pointer-events: auto;
198
+ }
199
+
200
+ html[data-theme="dark"] .tgflow-scroll-track {
201
+ border-right: 2px solid rgba(255, 255, 255, 0.18);
202
+ }
203
+
204
+ .tgflow-scroll-tick {
205
+ position: absolute;
206
+ right: -2px;
207
+ width: 5px;
208
+ height: 1.5px;
209
+ background: rgba(0, 0, 0, 0.25);
210
+ pointer-events: none;
211
+ }
212
+
213
+ html[data-theme="dark"] .tgflow-scroll-tick {
214
+ background: rgba(255, 255, 255, 0.3);
215
+ }
216
+
217
+ .tgflow-scroll-thumb {
218
+ position: absolute;
219
+ right: -3px;
220
+ top: 0;
221
+ width: 4px;
222
+ height: 36px;
223
+ background: #0088cc;
224
+ border-radius: 2px;
225
+ box-shadow: 0 0 10px rgba(0, 136, 204, 0.6);
226
+ transition: transform 0.1s cubic-bezier(0.2, 0, 0, 1);
227
+ pointer-events: none;
228
+ }
229
+
230
+ html[data-theme="dark"] .tgflow-scroll-thumb {
231
+ background: #24a1de;
232
+ box-shadow: 0 0 12px rgba(36, 161, 222, 0.7);
233
+ }
Binary file