Pytdbot 0.10.0.dev0__tar.gz → 0.10.0.dev1__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.0.dev1/PKG-INFO +146 -0
- pytdbot-0.10.0.dev1/Pytdbot.egg-info/PKG-INFO +146 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/Pytdbot.egg-info/SOURCES.txt +1 -1
- pytdbot-0.10.0.dev1/README.md +116 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pyproject.toml +16 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/__init__.py +1 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/client.py +56 -45
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/filters.py +1 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/handlers/td_updates.py +178 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/methods/methods.py +272 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/methods/td_functions.py +461 -35
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/__init__.py +65 -1
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/message.py +108 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/td_types.py +2003 -97
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/tdserver/schedule.py +16 -11
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/tdserver/stats.py +10 -7
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/__init__.py +2 -2
- pytdbot-0.10.0.dev1/pytdbot/utils/albums.py +17 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/text_format.py +1 -1
- pytdbot-0.10.0.dev0/PKG-INFO +0 -129
- pytdbot-0.10.0.dev0/Pytdbot.egg-info/PKG-INFO +0 -129
- pytdbot-0.10.0.dev0/README.md +0 -111
- pytdbot-0.10.0.dev0/pytdbot/utils/asyncio_utils.py +0 -10
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/LICENSE +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/MANIFEST.in +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/Pytdbot.egg-info/dependency_links.txt +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/Pytdbot.egg-info/requires.txt +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/Pytdbot.egg-info/top_level.txt +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/client_manager.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/exception/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/handlers/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/handlers/decorators.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/handlers/handler.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/methods/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/tdjson/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/tdjson/tdjson.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/callback_query.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/chatActions.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/file.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/bound_methods/sender_id.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/plugins/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/types/tdserver/__init__.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/escape.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/json_utils.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/obj_encoder.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/strings.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/pytdbot/utils/webapps.py +0 -0
- {pytdbot-0.10.0.dev0 → pytdbot-0.10.0.dev1}/setup.cfg +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Pytdbot
|
|
3
|
+
Version: 0.10.0.dev1
|
|
4
|
+
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
|
+
Author-email: AYMEN A <let.me.code.safe@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/pytdbot/client
|
|
8
|
+
Project-URL: Tracker, https://github.com/pytdbot/client/issues
|
|
9
|
+
Keywords: telegram,tdlib,bot,telegram-client,telegram-bot,bot-api,tdlib-python,tdlib-bot
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
|
+
Classifier: Framework :: AsyncIO
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Communications :: Chat
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: deepdiff
|
|
26
|
+
Requires-Dist: aio_pika
|
|
27
|
+
Provides-Extra: tdjson
|
|
28
|
+
Requires-Dist: tdjson; extra == "tdjson"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Pytdbot
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/Pytdbot)
|
|
34
|
+
[](https://github.com/tdlib/td)
|
|
35
|
+
[](https://pepy.tech/project/pytdbot)
|
|
36
|
+
[](https://t.me/pytdbotchat)
|
|
37
|
+
|
|
38
|
+
<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">
|
|
39
|
+
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
40
|
+
</a>
|
|
41
|
+
|
|
42
|
+
Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
`Pytdbot` offers numerous advantages, including:
|
|
47
|
+
|
|
48
|
+
- **Easy to Use**: Designed with simplicity in mind, making it accessible for developers
|
|
49
|
+
- **Performance**: Fast and powerful, making it ready to fight
|
|
50
|
+
- **Asynchronous**: Fully asynchronous that allows for non-blocking requests and improved responsiveness
|
|
51
|
+
- **Scalable**: Easily scalable using [TDLib Server](https://github.com/pytdbot/tdlib-server)
|
|
52
|
+
- **Well-typed**: Provides clear and well-defined methods and types to enhance developer experience
|
|
53
|
+
- **Decorator-Based Updates**: Simplifies the implementation of update handlers through a decorator pattern
|
|
54
|
+
- **Bound Methods**: Features types bound methods for improved usability
|
|
55
|
+
- **Unlimited Support**: Supports **Plugins**, [**filters**](pytdbot/filters.py#L23), [**TDLib**](https://github.com/tdlib/td) types/functions and much more
|
|
56
|
+
|
|
57
|
+
### Requirements
|
|
58
|
+
|
|
59
|
+
- Python 3.10+
|
|
60
|
+
- Telegram [API key](https://my.telegram.org/apps)
|
|
61
|
+
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
62
|
+
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
63
|
+
- [aio-pika](https://github.com/mosquito/aio-pika)
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
> For better performance, it's recommended to install [orjson](https://github.com/ijl/orjson#install) or [ujson](https://github.com/ultrajson/ultrajson#ultrajson).
|
|
68
|
+
|
|
69
|
+
You can install Pytdbot with TDLib included using pip:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install --upgrade pytdbot[tdjson]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If the installation fails, then install without **pre-built** TDLib:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install pytdbot
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
|
|
82
|
+
|
|
83
|
+
You could also install the development version using the following command:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install --pre pytdbot
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Examples
|
|
90
|
+
|
|
91
|
+
Basic example:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
|
|
95
|
+
import asyncio
|
|
96
|
+
import logging
|
|
97
|
+
|
|
98
|
+
from pytdbot import Client, types
|
|
99
|
+
|
|
100
|
+
logging.basicConfig(
|
|
101
|
+
level=logging.INFO,
|
|
102
|
+
format="[%(levelname)s][p %(process)d %(threadName)s][%(created)f][%(filename)s:%(lineno)d][%(funcName)s][%(name)s] %(message)s",
|
|
103
|
+
)
|
|
104
|
+
client = Client(
|
|
105
|
+
token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
|
|
106
|
+
api_id=0,
|
|
107
|
+
api_hash="API_HASH",
|
|
108
|
+
files_directory="BotDB", # Path where to store TDLib files
|
|
109
|
+
database_encryption_key="1234echobot$",
|
|
110
|
+
td_verbosity=2, # TDLib verbosity level
|
|
111
|
+
td_log=types.LogStreamFile("tdlib.log", 104857600), # Set TDLib log file path
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@client.on_updateNewMessage()
|
|
116
|
+
async def print_message(c: Client, message: types.UpdateNewMessage):
|
|
117
|
+
print(message)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@client.on_message()
|
|
121
|
+
async def say_hello(c: Client, message: types.Message):
|
|
122
|
+
msg = await message.reply_text(f"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... 🍳👨🍳", parse_mode="html")
|
|
123
|
+
|
|
124
|
+
async with message.action("choose_sticker"):
|
|
125
|
+
await asyncio.sleep(5)
|
|
126
|
+
|
|
127
|
+
await msg.edit_text("Boo! 👻 Just kidding.")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Run the client
|
|
132
|
+
asyncio.run(client.run())
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
For more examples, check the [examples](https://github.com/pytdbot/client/tree/main/examples) folder.
|
|
137
|
+
|
|
138
|
+
# Thanks to
|
|
139
|
+
|
|
140
|
+
- You for viewing or using this project.
|
|
141
|
+
|
|
142
|
+
- [@levlam](https://github.com/levlam) for maintaining [TDLib](https://github.com/tdlib/td) and for the help to create [Pytdbot](https://github.com/pytdbot/client).
|
|
143
|
+
|
|
144
|
+
# License
|
|
145
|
+
|
|
146
|
+
MIT [License](https://github.com/pytdbot/client/blob/main/LICENSE)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Pytdbot
|
|
3
|
+
Version: 0.10.0.dev1
|
|
4
|
+
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
|
+
Author-email: AYMEN A <let.me.code.safe@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/pytdbot/client
|
|
8
|
+
Project-URL: Tracker, https://github.com/pytdbot/client/issues
|
|
9
|
+
Keywords: telegram,tdlib,bot,telegram-client,telegram-bot,bot-api,tdlib-python,tdlib-bot
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
|
+
Classifier: Framework :: AsyncIO
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Communications :: Chat
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: deepdiff
|
|
26
|
+
Requires-Dist: aio_pika
|
|
27
|
+
Provides-Extra: tdjson
|
|
28
|
+
Requires-Dist: tdjson; extra == "tdjson"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Pytdbot
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/Pytdbot)
|
|
34
|
+
[](https://github.com/tdlib/td)
|
|
35
|
+
[](https://pepy.tech/project/pytdbot)
|
|
36
|
+
[](https://t.me/pytdbotchat)
|
|
37
|
+
|
|
38
|
+
<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">
|
|
39
|
+
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
40
|
+
</a>
|
|
41
|
+
|
|
42
|
+
Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
`Pytdbot` offers numerous advantages, including:
|
|
47
|
+
|
|
48
|
+
- **Easy to Use**: Designed with simplicity in mind, making it accessible for developers
|
|
49
|
+
- **Performance**: Fast and powerful, making it ready to fight
|
|
50
|
+
- **Asynchronous**: Fully asynchronous that allows for non-blocking requests and improved responsiveness
|
|
51
|
+
- **Scalable**: Easily scalable using [TDLib Server](https://github.com/pytdbot/tdlib-server)
|
|
52
|
+
- **Well-typed**: Provides clear and well-defined methods and types to enhance developer experience
|
|
53
|
+
- **Decorator-Based Updates**: Simplifies the implementation of update handlers through a decorator pattern
|
|
54
|
+
- **Bound Methods**: Features types bound methods for improved usability
|
|
55
|
+
- **Unlimited Support**: Supports **Plugins**, [**filters**](pytdbot/filters.py#L23), [**TDLib**](https://github.com/tdlib/td) types/functions and much more
|
|
56
|
+
|
|
57
|
+
### Requirements
|
|
58
|
+
|
|
59
|
+
- Python 3.10+
|
|
60
|
+
- Telegram [API key](https://my.telegram.org/apps)
|
|
61
|
+
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
62
|
+
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
63
|
+
- [aio-pika](https://github.com/mosquito/aio-pika)
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
> For better performance, it's recommended to install [orjson](https://github.com/ijl/orjson#install) or [ujson](https://github.com/ultrajson/ultrajson#ultrajson).
|
|
68
|
+
|
|
69
|
+
You can install Pytdbot with TDLib included using pip:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install --upgrade pytdbot[tdjson]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If the installation fails, then install without **pre-built** TDLib:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install pytdbot
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
|
|
82
|
+
|
|
83
|
+
You could also install the development version using the following command:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install --pre pytdbot
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Examples
|
|
90
|
+
|
|
91
|
+
Basic example:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
|
|
95
|
+
import asyncio
|
|
96
|
+
import logging
|
|
97
|
+
|
|
98
|
+
from pytdbot import Client, types
|
|
99
|
+
|
|
100
|
+
logging.basicConfig(
|
|
101
|
+
level=logging.INFO,
|
|
102
|
+
format="[%(levelname)s][p %(process)d %(threadName)s][%(created)f][%(filename)s:%(lineno)d][%(funcName)s][%(name)s] %(message)s",
|
|
103
|
+
)
|
|
104
|
+
client = Client(
|
|
105
|
+
token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
|
|
106
|
+
api_id=0,
|
|
107
|
+
api_hash="API_HASH",
|
|
108
|
+
files_directory="BotDB", # Path where to store TDLib files
|
|
109
|
+
database_encryption_key="1234echobot$",
|
|
110
|
+
td_verbosity=2, # TDLib verbosity level
|
|
111
|
+
td_log=types.LogStreamFile("tdlib.log", 104857600), # Set TDLib log file path
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@client.on_updateNewMessage()
|
|
116
|
+
async def print_message(c: Client, message: types.UpdateNewMessage):
|
|
117
|
+
print(message)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@client.on_message()
|
|
121
|
+
async def say_hello(c: Client, message: types.Message):
|
|
122
|
+
msg = await message.reply_text(f"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... 🍳👨🍳", parse_mode="html")
|
|
123
|
+
|
|
124
|
+
async with message.action("choose_sticker"):
|
|
125
|
+
await asyncio.sleep(5)
|
|
126
|
+
|
|
127
|
+
await msg.edit_text("Boo! 👻 Just kidding.")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Run the client
|
|
132
|
+
asyncio.run(client.run())
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
For more examples, check the [examples](https://github.com/pytdbot/client/tree/main/examples) folder.
|
|
137
|
+
|
|
138
|
+
# Thanks to
|
|
139
|
+
|
|
140
|
+
- You for viewing or using this project.
|
|
141
|
+
|
|
142
|
+
- [@levlam](https://github.com/levlam) for maintaining [TDLib](https://github.com/tdlib/td) and for the help to create [Pytdbot](https://github.com/pytdbot/client).
|
|
143
|
+
|
|
144
|
+
# License
|
|
145
|
+
|
|
146
|
+
MIT [License](https://github.com/pytdbot/client/blob/main/LICENSE)
|
|
@@ -34,7 +34,7 @@ pytdbot/types/tdserver/__init__.py
|
|
|
34
34
|
pytdbot/types/tdserver/schedule.py
|
|
35
35
|
pytdbot/types/tdserver/stats.py
|
|
36
36
|
pytdbot/utils/__init__.py
|
|
37
|
-
pytdbot/utils/
|
|
37
|
+
pytdbot/utils/albums.py
|
|
38
38
|
pytdbot/utils/escape.py
|
|
39
39
|
pytdbot/utils/json_utils.py
|
|
40
40
|
pytdbot/utils/obj_encoder.py
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Pytdbot
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/Pytdbot)
|
|
4
|
+
[](https://github.com/tdlib/td)
|
|
5
|
+
[](https://pepy.tech/project/pytdbot)
|
|
6
|
+
[](https://t.me/pytdbotchat)
|
|
7
|
+
|
|
8
|
+
<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
|
+
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
10
|
+
</a>
|
|
11
|
+
|
|
12
|
+
Pytdbot is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
`Pytdbot` offers numerous advantages, including:
|
|
17
|
+
|
|
18
|
+
- **Easy to Use**: Designed with simplicity in mind, making it accessible for developers
|
|
19
|
+
- **Performance**: Fast and powerful, making it ready to fight
|
|
20
|
+
- **Asynchronous**: Fully asynchronous that allows for non-blocking requests and improved responsiveness
|
|
21
|
+
- **Scalable**: Easily scalable using [TDLib Server](https://github.com/pytdbot/tdlib-server)
|
|
22
|
+
- **Well-typed**: Provides clear and well-defined methods and types to enhance developer experience
|
|
23
|
+
- **Decorator-Based Updates**: Simplifies the implementation of update handlers through a decorator pattern
|
|
24
|
+
- **Bound Methods**: Features types bound methods for improved usability
|
|
25
|
+
- **Unlimited Support**: Supports **Plugins**, [**filters**](pytdbot/filters.py#L23), [**TDLib**](https://github.com/tdlib/td) types/functions and much more
|
|
26
|
+
|
|
27
|
+
### Requirements
|
|
28
|
+
|
|
29
|
+
- Python 3.10+
|
|
30
|
+
- Telegram [API key](https://my.telegram.org/apps)
|
|
31
|
+
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
|
|
32
|
+
- [deepdiff](https://github.com/seperman/deepdiff)
|
|
33
|
+
- [aio-pika](https://github.com/mosquito/aio-pika)
|
|
34
|
+
|
|
35
|
+
### Installation
|
|
36
|
+
|
|
37
|
+
> For better performance, it's recommended to install [orjson](https://github.com/ijl/orjson#install) or [ujson](https://github.com/ultrajson/ultrajson#ultrajson).
|
|
38
|
+
|
|
39
|
+
You can install Pytdbot with TDLib included using pip:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install --upgrade pytdbot[tdjson]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If the installation fails, then install without **pre-built** TDLib:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install pytdbot
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
|
|
52
|
+
|
|
53
|
+
You could also install the development version using the following command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install --pre pytdbot
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Examples
|
|
60
|
+
|
|
61
|
+
Basic example:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
|
|
65
|
+
import asyncio
|
|
66
|
+
import logging
|
|
67
|
+
|
|
68
|
+
from pytdbot import Client, types
|
|
69
|
+
|
|
70
|
+
logging.basicConfig(
|
|
71
|
+
level=logging.INFO,
|
|
72
|
+
format="[%(levelname)s][p %(process)d %(threadName)s][%(created)f][%(filename)s:%(lineno)d][%(funcName)s][%(name)s] %(message)s",
|
|
73
|
+
)
|
|
74
|
+
client = Client(
|
|
75
|
+
token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
|
|
76
|
+
api_id=0,
|
|
77
|
+
api_hash="API_HASH",
|
|
78
|
+
files_directory="BotDB", # Path where to store TDLib files
|
|
79
|
+
database_encryption_key="1234echobot$",
|
|
80
|
+
td_verbosity=2, # TDLib verbosity level
|
|
81
|
+
td_log=types.LogStreamFile("tdlib.log", 104857600), # Set TDLib log file path
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@client.on_updateNewMessage()
|
|
86
|
+
async def print_message(c: Client, message: types.UpdateNewMessage):
|
|
87
|
+
print(message)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@client.on_message()
|
|
91
|
+
async def say_hello(c: Client, message: types.Message):
|
|
92
|
+
msg = await message.reply_text(f"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... 🍳👨🍳", parse_mode="html")
|
|
93
|
+
|
|
94
|
+
async with message.action("choose_sticker"):
|
|
95
|
+
await asyncio.sleep(5)
|
|
96
|
+
|
|
97
|
+
await msg.edit_text("Boo! 👻 Just kidding.")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# Run the client
|
|
102
|
+
asyncio.run(client.run())
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For more examples, check the [examples](https://github.com/pytdbot/client/tree/main/examples) folder.
|
|
107
|
+
|
|
108
|
+
# Thanks to
|
|
109
|
+
|
|
110
|
+
- You for viewing or using this project.
|
|
111
|
+
|
|
112
|
+
- [@levlam](https://github.com/levlam) for maintaining [TDLib](https://github.com/tdlib/td) and for the help to create [Pytdbot](https://github.com/pytdbot/client).
|
|
113
|
+
|
|
114
|
+
# License
|
|
115
|
+
|
|
116
|
+
MIT [License](https://github.com/pytdbot/client/blob/main/LICENSE)
|
|
@@ -8,7 +8,8 @@ dynamic = ["version"]
|
|
|
8
8
|
description = "Easy-to-use asynchronous TDLib wrapper for Python."
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
|
-
license =
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
12
13
|
authors = [{ name = "AYMEN A", email = "let.me.code.safe@gmail.com" }]
|
|
13
14
|
dependencies = ["deepdiff", "aio_pika"]
|
|
14
15
|
keywords = [
|
|
@@ -21,6 +22,20 @@ keywords = [
|
|
|
21
22
|
"tdlib-python",
|
|
22
23
|
"tdlib-bot",
|
|
23
24
|
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Programming Language :: Python :: 3.14",
|
|
34
|
+
"Programming Language :: Python :: 3.15",
|
|
35
|
+
"Framework :: AsyncIO",
|
|
36
|
+
"Topic :: Software Development :: Libraries",
|
|
37
|
+
"Topic :: Communications :: Chat",
|
|
38
|
+
]
|
|
24
39
|
|
|
25
40
|
[project.urls]
|
|
26
41
|
Source = "https://github.com/pytdbot/client"
|