Pytdbot 0.10.2.dev1__tar.gz → 1.0.0b1__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.
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/PKG-INFO +18 -6
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/Pytdbot.egg-info/PKG-INFO +18 -6
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/Pytdbot.egg-info/SOURCES.txt +16 -1
- pytdbot-1.0.0b1/Pytdbot.egg-info/requires.txt +17 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/Pytdbot.egg-info/top_level.txt +1 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/README.md +7 -4
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pyproject.toml +17 -7
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/__init__.py +1 -1
- pytdbot-1.0.0b1/pytdbot/ai/SKILL.md +299 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/ai/helpers.json +349 -84
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/ai/lookup.py +2 -2
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/client.py +10 -21
- pytdbot-1.0.0b1/pytdbot/docs.py +298 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/handlers/td_updates.py +296 -1
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/methods/methods.py +129 -15
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/methods/td_functions.py +462 -14
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/td_api.json +767 -51
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/__init__.py +51 -3
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/message.py +201 -32
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/td_types.py +2284 -512
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/__init__.py +10 -0
- pytdbot-1.0.0b1/pytdbot/utils/diff.py +72 -0
- pytdbot-1.0.0b1/pytdbot/utils/rich_converter.py +758 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/rich_messages.py +158 -4
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/text_format.py +236 -1
- pytdbot-1.0.0b1/tests/test_client.py +31 -0
- pytdbot-1.0.0b1/tests/test_error.py +27 -0
- pytdbot-1.0.0b1/tests/test_filters.py +16 -0
- pytdbot-1.0.0b1/tests/test_send.py +31 -0
- pytdbot-1.0.0b1/tests/test_utils_albums.py +15 -0
- pytdbot-1.0.0b1/tests/test_utils_common.py +11 -0
- pytdbot-1.0.0b1/tests/test_utils_diff.py +20 -0
- pytdbot-1.0.0b1/tests/test_utils_escape.py +21 -0
- pytdbot-1.0.0b1/tests/test_utils_json.py +32 -0
- pytdbot-1.0.0b1/tests/test_utils_obj.py +29 -0
- pytdbot-1.0.0b1/tests/test_utils_rich.py +131 -0
- pytdbot-1.0.0b1/tests/test_utils_strings.py +32 -0
- pytdbot-1.0.0b1/tests/test_utils_text_format.py +78 -0
- pytdbot-1.0.0b1/tests/test_utils_webapps.py +60 -0
- pytdbot-0.10.2.dev1/Pytdbot.egg-info/requires.txt +0 -7
- pytdbot-0.10.2.dev1/pytdbot/ai/SKILL.md +0 -215
- pytdbot-0.10.2.dev1/pytdbot/docs.py +0 -203
- pytdbot-0.10.2.dev1/pytdbot/utils/rich_converter.py +0 -530
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/LICENSE +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/MANIFEST.in +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/Pytdbot.egg-info/dependency_links.txt +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/Pytdbot.egg-info/entry_points.txt +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/llms.txt +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/ai/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/client_manager.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/exception/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/filters.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/handlers/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/handlers/decorators.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/handlers/handler.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/methods/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/tdjson/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/tdjson/tdjson.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/callback_query.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/chatActions.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/file.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/bound_methods/sender_id.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/plugins/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/tdserver/__init__.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/tdserver/schedule.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/types/tdserver/stats.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/albums.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/common.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/escape.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/json_utils.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/obj_encoder.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/strings.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/pytdbot/utils/webapps.py +0 -0
- {pytdbot-0.10.2.dev1 → pytdbot-1.0.0b1}/setup.cfg +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Pytdbot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0b1
|
|
4
4
|
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
5
|
Author-email: AYMEN A <let.me.code.safe@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Source, https://github.com/pytdbot/client
|
|
8
8
|
Project-URL: Tracker, https://github.com/pytdbot/client/issues
|
|
9
|
+
Project-URL: Documentation, https://pytdbot.pages.dev
|
|
9
10
|
Keywords: telegram,tdlib,bot,telegram-client,telegram-bot,bot-api,tdlib-python,tdlib-bot
|
|
10
11
|
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
@@ -22,19 +23,28 @@ Classifier: Topic :: Communications :: Chat
|
|
|
22
23
|
Requires-Python: >=3.10
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: deepdiff
|
|
26
26
|
Provides-Extra: tdjson
|
|
27
27
|
Requires-Dist: tdjson; extra == "tdjson"
|
|
28
28
|
Provides-Extra: nats
|
|
29
29
|
Requires-Dist: nats-py; extra == "nats"
|
|
30
|
+
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: properdocs>=1.6.7; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
33
|
+
Requires-Dist: mkdocs-autorefs; extra == "docs"
|
|
34
|
+
Requires-Dist: mkdocs-gen-files; extra == "docs"
|
|
35
|
+
Requires-Dist: mkdocs-literate-nav; extra == "docs"
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest; extra == "test"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "test"
|
|
30
39
|
Dynamic: license-file
|
|
31
40
|
|
|
32
41
|
# Pytdbot
|
|
33
42
|
|
|
34
43
|
[](https://pypi.org/project/Pytdbot)
|
|
35
|
-
[](https://github.com/tdlib/td)
|
|
45
|
+
[](https://pypi.org/project/Pytdbot)
|
|
37
46
|
[](https://t.me/pytdbotchat)
|
|
47
|
+
[](https://pytdbot.pages.dev)
|
|
38
48
|
|
|
39
49
|
<a href="https://cupofton.pages.dev/donate?a=UQCeySURtYxvqF2jNXlsFrXuTEqPjJhGx8uoev6tUbD_HELL&n=AYMEN&t=5&c=You+deserve+a+Cup+of+TON+for+Pytdbot%2521" target="_blank" rel="noopener">
|
|
40
50
|
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
@@ -60,7 +70,6 @@ Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for
|
|
|
60
70
|
- Python 3.10+
|
|
61
71
|
- Telegram [API key](https://my.telegram.org/apps)
|
|
62
72
|
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
63
|
-
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
64
73
|
|
|
65
74
|
### Installation
|
|
66
75
|
|
|
@@ -142,7 +151,10 @@ Pytdbot includes a skill and a local docs CLI so coding agents can use the libra
|
|
|
142
151
|
1. Install [Pytdbot](#installation)
|
|
143
152
|
2. Point your agent at the skill file:
|
|
144
153
|
- In this repo: [`pytdbot/ai/SKILL.md`](pytdbot/ai/SKILL.md)
|
|
145
|
-
- or using
|
|
154
|
+
- or using:
|
|
155
|
+
```bash
|
|
156
|
+
curl -O "https://raw.githubusercontent.com/pytdbot/client/refs/heads/main/pytdbot/ai/SKILL.md"
|
|
157
|
+
```
|
|
146
158
|
3. Register it the way your tool expects (project skill, agent rule, or “read this file first”)
|
|
147
159
|
|
|
148
160
|
The skill explains how Pytdbot is meant to be used; the CLI returns live signatures from your installed version.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Pytdbot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0b1
|
|
4
4
|
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
5
|
Author-email: AYMEN A <let.me.code.safe@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Source, https://github.com/pytdbot/client
|
|
8
8
|
Project-URL: Tracker, https://github.com/pytdbot/client/issues
|
|
9
|
+
Project-URL: Documentation, https://pytdbot.pages.dev
|
|
9
10
|
Keywords: telegram,tdlib,bot,telegram-client,telegram-bot,bot-api,tdlib-python,tdlib-bot
|
|
10
11
|
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
@@ -22,19 +23,28 @@ Classifier: Topic :: Communications :: Chat
|
|
|
22
23
|
Requires-Python: >=3.10
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: deepdiff
|
|
26
26
|
Provides-Extra: tdjson
|
|
27
27
|
Requires-Dist: tdjson; extra == "tdjson"
|
|
28
28
|
Provides-Extra: nats
|
|
29
29
|
Requires-Dist: nats-py; extra == "nats"
|
|
30
|
+
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: properdocs>=1.6.7; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
33
|
+
Requires-Dist: mkdocs-autorefs; extra == "docs"
|
|
34
|
+
Requires-Dist: mkdocs-gen-files; extra == "docs"
|
|
35
|
+
Requires-Dist: mkdocs-literate-nav; extra == "docs"
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest; extra == "test"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "test"
|
|
30
39
|
Dynamic: license-file
|
|
31
40
|
|
|
32
41
|
# Pytdbot
|
|
33
42
|
|
|
34
43
|
[](https://pypi.org/project/Pytdbot)
|
|
35
|
-
[](https://github.com/tdlib/td)
|
|
45
|
+
[](https://pypi.org/project/Pytdbot)
|
|
37
46
|
[](https://t.me/pytdbotchat)
|
|
47
|
+
[](https://pytdbot.pages.dev)
|
|
38
48
|
|
|
39
49
|
<a href="https://cupofton.pages.dev/donate?a=UQCeySURtYxvqF2jNXlsFrXuTEqPjJhGx8uoev6tUbD_HELL&n=AYMEN&t=5&c=You+deserve+a+Cup+of+TON+for+Pytdbot%2521" target="_blank" rel="noopener">
|
|
40
50
|
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
@@ -60,7 +70,6 @@ Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for
|
|
|
60
70
|
- Python 3.10+
|
|
61
71
|
- Telegram [API key](https://my.telegram.org/apps)
|
|
62
72
|
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
63
|
-
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
64
73
|
|
|
65
74
|
### Installation
|
|
66
75
|
|
|
@@ -142,7 +151,10 @@ Pytdbot includes a skill and a local docs CLI so coding agents can use the libra
|
|
|
142
151
|
1. Install [Pytdbot](#installation)
|
|
143
152
|
2. Point your agent at the skill file:
|
|
144
153
|
- In this repo: [`pytdbot/ai/SKILL.md`](pytdbot/ai/SKILL.md)
|
|
145
|
-
- or using
|
|
154
|
+
- or using:
|
|
155
|
+
```bash
|
|
156
|
+
curl -O "https://raw.githubusercontent.com/pytdbot/client/refs/heads/main/pytdbot/ai/SKILL.md"
|
|
157
|
+
```
|
|
146
158
|
3. Register it the way your tool expects (project skill, agent rule, or “read this file first”)
|
|
147
159
|
|
|
148
160
|
The skill explains how Pytdbot is meant to be used; the CLI returns live signatures from your installed version.
|
|
@@ -44,6 +44,7 @@ pytdbot/types/tdserver/stats.py
|
|
|
44
44
|
pytdbot/utils/__init__.py
|
|
45
45
|
pytdbot/utils/albums.py
|
|
46
46
|
pytdbot/utils/common.py
|
|
47
|
+
pytdbot/utils/diff.py
|
|
47
48
|
pytdbot/utils/escape.py
|
|
48
49
|
pytdbot/utils/json_utils.py
|
|
49
50
|
pytdbot/utils/obj_encoder.py
|
|
@@ -51,4 +52,18 @@ pytdbot/utils/rich_converter.py
|
|
|
51
52
|
pytdbot/utils/rich_messages.py
|
|
52
53
|
pytdbot/utils/strings.py
|
|
53
54
|
pytdbot/utils/text_format.py
|
|
54
|
-
pytdbot/utils/webapps.py
|
|
55
|
+
pytdbot/utils/webapps.py
|
|
56
|
+
tests/test_client.py
|
|
57
|
+
tests/test_error.py
|
|
58
|
+
tests/test_filters.py
|
|
59
|
+
tests/test_send.py
|
|
60
|
+
tests/test_utils_albums.py
|
|
61
|
+
tests/test_utils_common.py
|
|
62
|
+
tests/test_utils_diff.py
|
|
63
|
+
tests/test_utils_escape.py
|
|
64
|
+
tests/test_utils_json.py
|
|
65
|
+
tests/test_utils_obj.py
|
|
66
|
+
tests/test_utils_rich.py
|
|
67
|
+
tests/test_utils_strings.py
|
|
68
|
+
tests/test_utils_text_format.py
|
|
69
|
+
tests/test_utils_webapps.py
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Pytdbot
|
|
2
2
|
|
|
3
3
|
[](https://pypi.org/project/Pytdbot)
|
|
4
|
-
[](https://github.com/tdlib/td)
|
|
5
|
+
[](https://pypi.org/project/Pytdbot)
|
|
6
6
|
[](https://t.me/pytdbotchat)
|
|
7
|
+
[](https://pytdbot.pages.dev)
|
|
7
8
|
|
|
8
9
|
<a href="https://cupofton.pages.dev/donate?a=UQCeySURtYxvqF2jNXlsFrXuTEqPjJhGx8uoev6tUbD_HELL&n=AYMEN&t=5&c=You+deserve+a+Cup+of+TON+for+Pytdbot%2521" target="_blank" rel="noopener">
|
|
9
10
|
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
@@ -29,7 +30,6 @@ Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for
|
|
|
29
30
|
- Python 3.10+
|
|
30
31
|
- Telegram [API key](https://my.telegram.org/apps)
|
|
31
32
|
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
32
|
-
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
33
33
|
|
|
34
34
|
### Installation
|
|
35
35
|
|
|
@@ -111,7 +111,10 @@ Pytdbot includes a skill and a local docs CLI so coding agents can use the libra
|
|
|
111
111
|
1. Install [Pytdbot](#installation)
|
|
112
112
|
2. Point your agent at the skill file:
|
|
113
113
|
- In this repo: [`pytdbot/ai/SKILL.md`](pytdbot/ai/SKILL.md)
|
|
114
|
-
- or using
|
|
114
|
+
- or using:
|
|
115
|
+
```bash
|
|
116
|
+
curl -O "https://raw.githubusercontent.com/pytdbot/client/refs/heads/main/pytdbot/ai/SKILL.md"
|
|
117
|
+
```
|
|
115
118
|
3. Register it the way your tool expects (project skill, agent rule, or “read this file first”)
|
|
116
119
|
|
|
117
120
|
The skill explains how Pytdbot is meant to be used; the CLI returns live signatures from your installed version.
|
|
@@ -11,7 +11,7 @@ requires-python = ">=3.10"
|
|
|
11
11
|
license = "MIT"
|
|
12
12
|
license-files = ["LICENSE"]
|
|
13
13
|
authors = [{ name = "AYMEN A", email = "let.me.code.safe@gmail.com" }]
|
|
14
|
-
dependencies = [
|
|
14
|
+
dependencies = []
|
|
15
15
|
keywords = [
|
|
16
16
|
"telegram",
|
|
17
17
|
"tdlib",
|
|
@@ -40,23 +40,33 @@ classifiers = [
|
|
|
40
40
|
[project.urls]
|
|
41
41
|
Source = "https://github.com/pytdbot/client"
|
|
42
42
|
Tracker = "https://github.com/pytdbot/client/issues"
|
|
43
|
+
Documentation = "https://pytdbot.pages.dev"
|
|
43
44
|
|
|
44
45
|
[project.optional-dependencies]
|
|
45
46
|
tdjson = ["tdjson"]
|
|
46
47
|
nats = ["nats-py"]
|
|
48
|
+
docs = [
|
|
49
|
+
"properdocs>=1.6.7",
|
|
50
|
+
"mkdocs-material",
|
|
51
|
+
"mkdocs-autorefs",
|
|
52
|
+
"mkdocs-gen-files",
|
|
53
|
+
"mkdocs-literate-nav",
|
|
54
|
+
]
|
|
55
|
+
test = ["pytest", "pytest-asyncio>=0.24"]
|
|
47
56
|
|
|
48
57
|
[project.scripts]
|
|
49
58
|
pytdbot-docs = "pytdbot.docs:main"
|
|
50
59
|
|
|
51
60
|
[tool.setuptools.packages.find]
|
|
52
|
-
exclude = ["examples"]
|
|
61
|
+
exclude = ["examples", "docs", "tests"]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
asyncio_mode = "auto"
|
|
66
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
53
67
|
|
|
54
68
|
[tool.setuptools.package-data]
|
|
55
|
-
pytdbot = [
|
|
56
|
-
"td_api.*",
|
|
57
|
-
"ai/SKILL.md",
|
|
58
|
-
"ai/helpers.json",
|
|
59
|
-
]
|
|
69
|
+
pytdbot = ["td_api.*", "ai/SKILL.md", "ai/helpers.json"]
|
|
60
70
|
|
|
61
71
|
[tool.setuptools.dynamic]
|
|
62
72
|
version = { attr = "pytdbot.__version__" }
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pytdbot
|
|
3
|
+
description: >
|
|
4
|
+
Write Telegram bots and userbots with Pytdbot (async TDLib wrapper
|
|
5
|
+
with high-level helpers; not the Telegram Bot API).
|
|
6
|
+
Use when the user works with Pytdbot, TDLib, or pytdbot.Client.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pytdbot
|
|
10
|
+
|
|
11
|
+
Pytdbot is an async [TDLib](https://github.com/tdlib/td) wrapper for Telegram users/bots in Python, with high-level helpers (bound methods, Client helpers, utils). It is **not** the HTTP Telegram Bot API — do not use Bot API method names, types, or libraries. Use Pytdbot/TDLib names and types only.
|
|
12
|
+
|
|
13
|
+
## `python -m pytdbot.docs` (use this for the API)
|
|
14
|
+
|
|
15
|
+
Before calling an unfamiliar method or building a type, run the docs CLI. It searches the installed library and prints parameters, types, and descriptions.
|
|
16
|
+
|
|
17
|
+
| Command | When to use | Example |
|
|
18
|
+
| -------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
19
|
+
| `search <query>` | Find symbols by keyword | `python -m pytdbot.docs search "send photo"` |
|
|
20
|
+
| `function <name…>` | Full TDLib method signature(s) | `python -m pytdbot.docs function sendMessage getChat` |
|
|
21
|
+
| `type <name…>` | Fields of a TDLib type | `python -m pytdbot.docs type message` |
|
|
22
|
+
| `class <name…>` | Abstract class → concrete types | `python -m pytdbot.docs class InputFile` |
|
|
23
|
+
| `update <name…>` | Update payload shape | `python -m pytdbot.docs update updateNewMessage` |
|
|
24
|
+
| `helper [name…]` | Pytdbot bound methods, Client helpers, utils | `python -m pytdbot.docs helper reply_text reply_photo` |
|
|
25
|
+
| `helper -q <query>` | Search helpers only | `python -m pytdbot.docs helper -q escape` |
|
|
26
|
+
| `batch <kind:name…>` | Mixed lookups in one call | `python -m pytdbot.docs batch function:sendMessage type:message helper:reply_text` |
|
|
27
|
+
| `stats` | Counts / TDLib version | `python -m pytdbot.docs stats` |
|
|
28
|
+
|
|
29
|
+
Workflow: `search` → pick a name → `function` / `type` / `class` / `helper` for full detail.
|
|
30
|
+
Prefer one invocation: pass several names, or `batch kind:name …` (`function`/`fn`, `type`, `class`, `update`, `helper`).
|
|
31
|
+
Flags: `--json` for machine-readable output (one name is still a single object; several names and `batch` are a JSON array); `search --kind function` (or `type`, `class`, `update`, `helper`) to narrow results.
|
|
32
|
+
Also available as `pytdbot-docs` after install. Same commands either way.
|
|
33
|
+
|
|
34
|
+
## Preference order
|
|
35
|
+
|
|
36
|
+
1. Bound methods — `message.reply_text`, `message.reply_photo`, `message.text`, …
|
|
37
|
+
2. Client helpers — `sendTextMessage`, `sendPhoto`, `sendAlbum`, `parseText`, …
|
|
38
|
+
3. `pytdbot.utils` — formatting (including rich messages), callback data, escapes, …
|
|
39
|
+
4. TDLib methods on `Client` — `sendMessage`, `getChat`, … (camelCase)
|
|
40
|
+
|
|
41
|
+
## Basic bot
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import asyncio
|
|
45
|
+
from pytdbot import Client, types
|
|
46
|
+
|
|
47
|
+
client = Client(
|
|
48
|
+
token="BOT_TOKEN",
|
|
49
|
+
api_id=0,
|
|
50
|
+
api_hash="API_HASH",
|
|
51
|
+
files_directory="BotDB",
|
|
52
|
+
database_encryption_key="change-me",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@client.on_message()
|
|
56
|
+
async def on_msg(c: Client, message: types.Message):
|
|
57
|
+
if message.text:
|
|
58
|
+
await message.reply_text(message.text)
|
|
59
|
+
|
|
60
|
+
asyncio.run(client.run())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Userbot: `user_bot=True` (no token) and handle authorization — see `examples/userbot.py`.
|
|
64
|
+
|
|
65
|
+
## Handlers
|
|
66
|
+
|
|
67
|
+
- `async def handler(client, update_or_message)`
|
|
68
|
+
- `@client.on_message()` → `types.Message`
|
|
69
|
+
- `@client.on_updateNewMessage()` / other `on_update…` → full update
|
|
70
|
+
- Filters: `from pytdbot import filters` → `filters.create(...)` then `@client.on_message(filters=my_filter)`
|
|
71
|
+
|
|
72
|
+
## Common patterns
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
@client.on_message()
|
|
76
|
+
async def echo(c: Client, message: types.Message):
|
|
77
|
+
if isinstance(message.content, types.MessageText):
|
|
78
|
+
await message.reply_text(message.text, entities=message.entities)
|
|
79
|
+
elif isinstance(message.content, types.MessagePhoto):
|
|
80
|
+
await message.reply_photo(message.remote_file_id, caption=message.caption)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Parse mode on helpers: `"html"`, `"markdown"`, `"markdownv2"` (or `default_parse_mode=` on `Client`).
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
await message.reply_text("<b>hi</b>", parse_mode="html")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Inline keyboard + callback (with `utils.callback_data`). For **rich messages**, use `utils.tg_button` instead unless the user asks for an inline keyboard — see [Rich messages](#rich-messages).
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from pytdbot import utils
|
|
93
|
+
|
|
94
|
+
await message.reply_text(
|
|
95
|
+
"Pick",
|
|
96
|
+
reply_markup=types.ReplyMarkupInlineKeyboard(
|
|
97
|
+
rows=[[
|
|
98
|
+
types.InlineKeyboardButton(
|
|
99
|
+
text="OK",
|
|
100
|
+
type=types.InlineKeyboardButtonTypeCallback(
|
|
101
|
+
data=utils.callback_data("ok", {"id": 1})
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
]]
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
@client.on_updateNewCallbackQuery()
|
|
109
|
+
async def on_cb(c: Client, update: types.UpdateNewCallbackQuery):
|
|
110
|
+
cb = utils.load_callback_data(update.payload.data)
|
|
111
|
+
# cb.action, cb.data
|
|
112
|
+
await update.answer(text="done")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
async with message.action("typing"):
|
|
117
|
+
await asyncio.sleep(1)
|
|
118
|
+
await message.reply_text("Done")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
await client.sendPhoto(chat_id, photo="path_or_remote_id", caption="Hi", parse_mode="html")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Raw TDLib: look up with `function` / `type` first, then call; build objects with `types.*`.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
chat = await client.getChat(chat_id=chat_id)
|
|
129
|
+
if not chat: # Error is falsy; success types are truthy
|
|
130
|
+
return
|
|
131
|
+
# use chat...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## `pytdbot.utils`
|
|
135
|
+
|
|
136
|
+
Import: `from pytdbot import utils` (or `from pytdbot.utils import bold, escape_html, …`).
|
|
137
|
+
Signatures: `python -m pytdbot.docs helper bold` / `helper -q webapp`.
|
|
138
|
+
|
|
139
|
+
- **Text format** (HTML by default; MarkdownV2 with `html=False`): `bold`, `italic`, `underline`, `strikethrough`, `spoiler`, `code`, `pre`, `pre_code`, `hyperlink`, `mention`, `custom_emoji`, `quote`, `rtl`, `ltr`
|
|
140
|
+
- **Escape**: `escape_html`, `escape_markdown`
|
|
141
|
+
- **Callback buttons**: `callback_data(action, data=None)` → `bytes` (max 64); `load_callback_data(data)` → `.action` / `.data`
|
|
142
|
+
- **Mini Apps (Web App)**: `create_webapp_secret_key(bot_token)` → secret; `parse_webapp_data(secret_key, init_data, max_data_age=60)` → validated `dict` (raises `WebAppDataInvalid` / `WebAppDataOutdated` / `WebAppDataMismatch` from `pytdbot.exception`)
|
|
143
|
+
- **Flood / retry**: `get_retry_after_time(error_message)`
|
|
144
|
+
- **Other**: `get_bot_id_from_token`, `get_message_sender_id`
|
|
145
|
+
- **Rich messages**: builders and send helpers — see [Rich messages](#rich-messages)
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from pytdbot import utils
|
|
149
|
+
|
|
150
|
+
text = f"Hello {utils.bold(name)} — {utils.hyperlink('site', url)}"
|
|
151
|
+
await message.reply_text(text, parse_mode="html")
|
|
152
|
+
|
|
153
|
+
# Mini App initData validation
|
|
154
|
+
secret = utils.create_webapp_secret_key(bot_token)
|
|
155
|
+
data = utils.parse_webapp_data(secret, init_data)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Rich messages
|
|
159
|
+
|
|
160
|
+
TDLib rich messages (not Bot API). Build HTML with `pytdbot.utils` helpers (they return strings; join with `+`), then send. Signatures: `python -m pytdbot.docs helper reply_rich_message` / `helper tg_button` / `helper -q tg_`.
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from pytdbot import utils
|
|
164
|
+
|
|
165
|
+
html = (
|
|
166
|
+
utils.heading(1, "Title")
|
|
167
|
+
+ utils.paragraph("Hello ", utils.bold(name))
|
|
168
|
+
+ utils.unordered_list("one", "two")
|
|
169
|
+
+ utils.tg_button_row(
|
|
170
|
+
utils.tg_button("OK", type="callback_data", data="ok", style="success"),
|
|
171
|
+
utils.tg_button("Site", type="url", url="https://example.com"),
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
await message.reply_rich_message(html=html)
|
|
175
|
+
# or: await client.sendRichMessage(chat_id, html=html)
|
|
176
|
+
# markdown= instead of html= is also accepted (not both)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Edit later with `client.editRichMessage`. Convert a received rich payload with `utils.rich_message_to_html`.
|
|
180
|
+
|
|
181
|
+
### Formatting
|
|
182
|
+
|
|
183
|
+
Usual HTML helpers work inside rich HTML too: `bold`, `italic`, `underline`, `strikethrough`, `spoiler`, `code`, `pre` / `pre_code`, `hyperlink`, `mention`, `custom_emoji`, `quote`.
|
|
184
|
+
|
|
185
|
+
| Helper | Role |
|
|
186
|
+
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
187
|
+
| `paragraph(*children)` | Paragraph. Put inline `tg_button`s here |
|
|
188
|
+
| `heading(level, text, name=None)` | `h1`–`h6`; optional in-doc anchor `name` |
|
|
189
|
+
| `footer(*children)`, `newline(count=1)`, `horizontal_rule()` | Footer, `<br>`, `<hr>` |
|
|
190
|
+
| `marked`, `subscript`, `superscript` | Highlight / sub / sup |
|
|
191
|
+
| `thinking(text)` | Telegram thinking block |
|
|
192
|
+
| `tg_math` / `tg_math_block` | Inline / block LaTeX |
|
|
193
|
+
| `tg_time(unix, format, text="")` | Date-time entity |
|
|
194
|
+
| `tg_reference(name, text)`, `anchor(name)`, `in_doc_link(anchor, text)` | In-document references |
|
|
195
|
+
| `email_link(address, text)`, `phone(number, text)` | `mailto:` / `tel:` |
|
|
196
|
+
| `blockquote(*children, cite=None, expandable=False)`, `aside(*children, cite=None)` | Quotes |
|
|
197
|
+
| `details(*children, summary, open=False)` | Collapsible block |
|
|
198
|
+
| `unordered_list(*items)`, `ordered_list(*items, start=, type=, reversed=)`, `list_item(*children, value=, checked=, type=)` | Lists; `checked=` makes a checkbox item |
|
|
199
|
+
| `table(*rows, bordered=, striped=, compact=, caption=)`, `table_row`, `table_header`, `table_cell`, `table_header_cell` | Tables (`align` / `valign` / `colspan` / `rowspan` on cells) |
|
|
200
|
+
| `image(src, alt=, spoiler=)`, `video(src, spoiler=)`, `audio(src)`, `tg_document(src)` | Media (`src` URL or `tg://…` media id) |
|
|
201
|
+
| `figure(*children)`, `figcaption(*children)` | Figure + caption |
|
|
202
|
+
| `tg_map(lat, long, zoom)`, `tg_collage(*media, caption=)`, `tg_slideshow(*media, caption=)` | Map / collage / slideshow |
|
|
203
|
+
|
|
204
|
+
### Buttons
|
|
205
|
+
|
|
206
|
+
If you are sending a **rich message**, prefer `utils.tg_button` / `utils.tg_button_row` (rich-message buttons). Do **not** attach `reply_markup=types.ReplyMarkupInlineKeyboard(...)` unless the user explicitly asks for an inline keyboard.
|
|
207
|
+
|
|
208
|
+
- **Inline** (in the text flow): put `tg_button(...)` inside `paragraph(...)`.
|
|
209
|
+
- **Row** (full-width bar): pass buttons to `tg_button_row(*buttons, align=None)`. `align` is `"left"`, `"center"`, or `"right"`; omit it for full-width buttons.
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
html = utils.paragraph(
|
|
213
|
+
"Pick: ",
|
|
214
|
+
utils.tg_button("Go", type="callback_data", data=utils.callback_data("ok", {"id": 1}), style="success"),
|
|
215
|
+
) + utils.tg_button_row(
|
|
216
|
+
utils.tg_button("Open", type="url", url="https://t.me"),
|
|
217
|
+
utils.tg_button("Copy", type="copy_text", text="hello"),
|
|
218
|
+
)
|
|
219
|
+
await message.reply_rich_message(html=html)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`tg_button(*label, type, …)`:
|
|
223
|
+
|
|
224
|
+
| `type` | Extra args |
|
|
225
|
+
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
226
|
+
| `url` | `url=`; user buttons: `url="tg://user?id=…"` |
|
|
227
|
+
| `callback_data` | `data=` (`str` or `bytes` from `utils.callback_data`) |
|
|
228
|
+
| `web_app` | `url=` |
|
|
229
|
+
| `login_url` | `url=`, optional `forward_text=`, `request_write_access=` |
|
|
230
|
+
| `switch_inline_query` / `switch_inline_query_current_chat` | `query=` |
|
|
231
|
+
| `switch_inline_query_chosen_chat` | `query=`, `allow_user_chats=`, `allow_bot_chats=`, `allow_group_chats=`, `allow_channel_chats=` |
|
|
232
|
+
| `copy_text` | `text=` (clipboard) |
|
|
233
|
+
| `disabled` | no extra args |
|
|
234
|
+
|
|
235
|
+
`style=` (optional): `"primary"`, `"danger"`, `"success"`, `"link"` (`"link"` only on callback buttons).
|
|
236
|
+
|
|
237
|
+
Callback presses are still `on_updateNewCallbackQuery` + `utils.load_callback_data` / `update.answer(...)`, same as a normal inline keyboard.
|
|
238
|
+
|
|
239
|
+
## Plugins
|
|
240
|
+
|
|
241
|
+
Split handlers into modules under a folder; pass `types.Plugins` into `Client`.
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from pytdbot import Client, types
|
|
245
|
+
|
|
246
|
+
client = Client(
|
|
247
|
+
token="BOT_TOKEN",
|
|
248
|
+
api_id=0,
|
|
249
|
+
api_hash="API_HASH",
|
|
250
|
+
files_directory="BotDB",
|
|
251
|
+
database_encryption_key="change-me",
|
|
252
|
+
plugins=types.Plugins(
|
|
253
|
+
folder="plugins/",
|
|
254
|
+
# optional: only these modules (dotted path = folder + file)
|
|
255
|
+
# include=["plugins.rules", "plugins.admin.ban"],
|
|
256
|
+
# optional: skip modules
|
|
257
|
+
# exclude=["plugins.experimental"],
|
|
258
|
+
),
|
|
259
|
+
)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**`Plugins`**
|
|
263
|
+
|
|
264
|
+
| Arg | Meaning |
|
|
265
|
+
| --------- | ------------------------------------------------------------------------------------------ |
|
|
266
|
+
| `folder` | Directory to scan for `*.py` (recursive) |
|
|
267
|
+
| `include` | If set, only load modules whose path matches (e.g. `plugins.rules` for `plugins/rules.py`) |
|
|
268
|
+
| `exclude` | If set (and no `include`), skip these module paths |
|
|
269
|
+
|
|
270
|
+
**Plugin module** (`plugins/ping.py`) — decorate with `Client.…` (no client instance); those handlers are picked up when the client starts with `plugins=…`:
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
from pytdbot import Client, types, filters
|
|
274
|
+
|
|
275
|
+
private = filters.create(lambda _, m: m.chat_id > 0)
|
|
276
|
+
|
|
277
|
+
@Client.on_message(filters=private)
|
|
278
|
+
async def ping(c: Client, message: types.Message):
|
|
279
|
+
if message.text == "/ping":
|
|
280
|
+
await message.reply_text("pong")
|
|
281
|
+
|
|
282
|
+
@Client.on_updateNewCallbackQuery()
|
|
283
|
+
async def on_cb(c: Client, update: types.UpdateNewCallbackQuery):
|
|
284
|
+
await update.answer(text="ok")
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Same decorator API as on a live client: `on_message`, `on_updateNewMessage`, `on_updateNewCallbackQuery`, `initializer`, `finalizer`, other `on_update…`, plus `filters=`, `position=`, `timeout=`. Handlers must be `async`.
|
|
288
|
+
|
|
289
|
+
**Runtime**
|
|
290
|
+
|
|
291
|
+
- Loaded when `Client` is constructed with `plugins=…` (folder must be importable; usually run from project root so `plugins.*` imports work).
|
|
292
|
+
- `client.reload_plugins()` — reloads plugin modules (**dev only**, not for production). Handlers registered on the client instance itself are left alone.
|
|
293
|
+
- `client.remove_handler(func)` — remove a specific handler function.
|
|
294
|
+
|
|
295
|
+
## Details
|
|
296
|
+
|
|
297
|
+
- Types: `from pytdbot import Client, types` → `types.SomeType(...)`.
|
|
298
|
+
- Bots: `token=`; userbots: `user_bot=True` + authorization updates.
|
|
299
|
+
- `files_directory` + `database_encryption_key` required; one live client per directory.
|