tdjson 1.8.59.post1__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
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.
- tdjson/__init__.py +12 -0
- tdjson/_version.py +3 -0
- tdjson/py.typed +0 -0
- tdjson/tdjson.cpp +55 -0
- tdjson/tdjson_ext.cpython-310-aarch64-linux-gnu.so +0 -0
- tdjson/tdjson_ext.pyi +15 -0
- tdjson-1.8.59.post1.dist-info/METADATA +79 -0
- tdjson-1.8.59.post1.dist-info/RECORD +11 -0
- tdjson-1.8.59.post1.dist-info/WHEEL +6 -0
- tdjson-1.8.59.post1.dist-info/licenses/LICENSE +21 -0
- tdjson.libs/libtdjson-6a40a443.so.1.8.59 +0 -0
tdjson/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .tdjson_ext import td_create_client_id, td_send, td_receive, td_execute
|
|
2
|
+
from ._version import __version__, __copyright__, __license__
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"td_create_client_id",
|
|
6
|
+
"td_send",
|
|
7
|
+
"td_receive",
|
|
8
|
+
"td_execute",
|
|
9
|
+
"__version__",
|
|
10
|
+
"__copyright__",
|
|
11
|
+
"__license__",
|
|
12
|
+
]
|
tdjson/_version.py
ADDED
tdjson/py.typed
ADDED
|
File without changes
|
tdjson/tdjson.cpp
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#include <nanobind/nanobind.h>
|
|
2
|
+
#include <nanobind/stl/optional.h>
|
|
3
|
+
#include <optional>
|
|
4
|
+
#include <td/telegram/td_json_client.h>
|
|
5
|
+
|
|
6
|
+
namespace nb = nanobind;
|
|
7
|
+
using bytes = nb::bytes;
|
|
8
|
+
|
|
9
|
+
void send(int client_id, bytes request) { td_send(client_id, request.c_str()); }
|
|
10
|
+
|
|
11
|
+
std::optional<bytes> receive(double timeout) {
|
|
12
|
+
const char *result;
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
nb::gil_scoped_release release;
|
|
16
|
+
result = td_receive(timeout);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!result) {
|
|
20
|
+
return std::nullopt;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return bytes(result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
std::optional<bytes> execute(bytes request) {
|
|
27
|
+
const char *result;
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
nb::gil_scoped_release release;
|
|
31
|
+
result = td_execute(request.c_str());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!result) {
|
|
35
|
+
return std::nullopt;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return bytes(result);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
NB_MODULE(tdjson_ext, m) {
|
|
42
|
+
m.def("td_create_client_id", &td_create_client_id,
|
|
43
|
+
nb::call_guard<nb::gil_scoped_release>(),
|
|
44
|
+
"Returns an opaque identifier of a new TDLib instance")
|
|
45
|
+
.def("td_send", &send, nb::call_guard<nb::gil_scoped_release>(),
|
|
46
|
+
nb::arg("client_id"), nb::arg("request"),
|
|
47
|
+
"Sends request to the TDLib client. May be called from any thread")
|
|
48
|
+
.def(
|
|
49
|
+
"td_receive", &receive, nb::arg("timeout"),
|
|
50
|
+
"Receives incoming updates and request responses. Must not be called "
|
|
51
|
+
"simultaneously from two different "
|
|
52
|
+
"threads")
|
|
53
|
+
.def("td_execute", &execute, nb::arg("request"),
|
|
54
|
+
"Synchronously executes a TDLib request");
|
|
55
|
+
}
|
|
Binary file
|
tdjson/tdjson_ext.pyi
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
def td_create_client_id() -> int:
|
|
4
|
+
"""Returns an opaque identifier of a new TDLib instance"""
|
|
5
|
+
|
|
6
|
+
def td_send(client_id: int, request: bytes) -> None:
|
|
7
|
+
"""Sends request to the TDLib client. May be called from any thread"""
|
|
8
|
+
|
|
9
|
+
def td_receive(timeout: float) -> bytes | None:
|
|
10
|
+
"""
|
|
11
|
+
Receives incoming updates and request responses. Must not be called simultaneously from two different threads
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def td_execute(request: bytes) -> bytes | None:
|
|
15
|
+
"""Synchronously executes a TDLib request"""
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: tdjson
|
|
3
|
+
Version: 1.8.59.post1
|
|
4
|
+
Summary: A high-performance Python binding for TDLib, outperforming ctypes and bundling pre-built binaries for effortless setup on Linux and Windows
|
|
5
|
+
Keywords: tdlib,telegram,python-binding,high-performance,linux,windows
|
|
6
|
+
Author-Email: AYMEN <let.me.code.safe@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Source, https://github.com/AYMENJD/tdjson
|
|
9
|
+
Project-URL: Tracker, https://github.com/AYMENJD/tdjson/issues
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# tdjson [](https://pypi.org/project/tdjson) [](https://github.com/tdlib/td)  [](https://pepy.tech/project/tdjson)
|
|
14
|
+
|
|
15
|
+
`tdjson` is a high-performance Python binding for [TDLib](https://github.com/tdlib/td) JSON interface.
|
|
16
|
+
|
|
17
|
+
By bundling **pre-built** TDLib binaries, it eliminates the effort for **manual** compilation and offers performance advantage over traditional `ctypes` wrappers, making it a reliable core for projects like [Pytdbot](https://github.com/pytdbot/client)
|
|
18
|
+
|
|
19
|
+
<a href="https://cupofton.pages.dev/donate?a=UQCeySURtYxvqF2jNXlsFrXuTEqPjJhGx8uoev6tUbD_HELL&n=AYMEN&t=1&c=You+deserve+a+Cup+of+TON+for+tdjson%2521" target="_blank" rel="noopener">
|
|
20
|
+
<img src="https://cupofton.pages.dev/assets/badge-1.svg" alt="Buy me a Cup of TON" style="width: 600px; height: auto;">
|
|
21
|
+
</a>
|
|
22
|
+
|
|
23
|
+
## Compatibility
|
|
24
|
+
|
|
25
|
+
`tdjson` is compatible with the following platforms:
|
|
26
|
+
|
|
27
|
+
* **Linux** (`x86_64` and `aarch64`)
|
|
28
|
+
* Requires `glibc 2.17+`.
|
|
29
|
+
* Debian 8+, Ubuntu 13.10+, Fedora 19+, RHEL 7+
|
|
30
|
+
|
|
31
|
+
* **Windows** (`x86_64`) — Windows 7+
|
|
32
|
+
|
|
33
|
+
* **macOS** (`aarch64`) — macOS 11+
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
You can install `tdjson` directly from PyPI:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install tdjson
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Here’s a quick example to get you started:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import json
|
|
49
|
+
import tdjson
|
|
50
|
+
|
|
51
|
+
# Create a new TDLib client
|
|
52
|
+
client_id = tdjson.td_create_client_id()
|
|
53
|
+
|
|
54
|
+
# Send a request to TDLib
|
|
55
|
+
request = {"@type": "getOption", "name": "version"}
|
|
56
|
+
tdjson.td_send(client_id, json.dumps(request).encode("utf-8"))
|
|
57
|
+
|
|
58
|
+
# Receive updates or responses
|
|
59
|
+
response = tdjson.td_receive(10.0)
|
|
60
|
+
print(response)
|
|
61
|
+
|
|
62
|
+
# Synchronously execute a TDLib request
|
|
63
|
+
result = tdjson.td_execute(
|
|
64
|
+
json.dumps(
|
|
65
|
+
{
|
|
66
|
+
"@type": "getTextEntities",
|
|
67
|
+
"text": "@telegram /test_command https://telegram.org telegram.me",
|
|
68
|
+
"@extra": ["5", 7.0, "a"],
|
|
69
|
+
}
|
|
70
|
+
).encode("utf-8")
|
|
71
|
+
)
|
|
72
|
+
print(result)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For more detailed examples, check out the [examples](https://github.com/AYMENJD/tdjson/blob/main/examples) folder.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT [LICENSE](https://github.com/AYMENJD/tdjson/blob/main/LICENSE)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
tdjson/__init__.py,sha256=LhoirwPIPH88LTvImArPsBu7hSxoRlO3BOsn4-z_B2I,291
|
|
2
|
+
tdjson/_version.py,sha256=-qQNI9HsELBgvEa-dfbN8tDuqs7vFmKCJlA4LIQGEUU,102
|
|
3
|
+
tdjson/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
tdjson/tdjson.cpp,sha256=LW09OD9I0oZUFxu6nyctjMk83bjCSLs2W2P6FrJG-gA,1436
|
|
5
|
+
tdjson/tdjson_ext.cpython-310-aarch64-linux-gnu.so,sha256=v5LwWqnwNsIKJCSwve6Ii93cmCdFZwRqeznDkmrwrWg,284441
|
|
6
|
+
tdjson/tdjson_ext.pyi,sha256=ihr4Ndxr3-ZwBbtMXEIutBOu-3BkAo-Cn854g3kwN6k,505
|
|
7
|
+
tdjson.libs/libtdjson-6a40a443.so.1.8.59,sha256=lRJhsdbHOZjPDjBOW2IcZyq_A-g4-4Qpo15onFDVK_E,48960865
|
|
8
|
+
tdjson-1.8.59.post1.dist-info/METADATA,sha256=HWB5KOZbTCU8PO2weH_hUk_H_osh3e2AT2oZngcOb4Q,3037
|
|
9
|
+
tdjson-1.8.59.post1.dist-info/WHEEL,sha256=e8r2Onm5NNvlP7oexPErjEYtutEfns1NIR2WhYHCUPg,158
|
|
10
|
+
tdjson-1.8.59.post1.dist-info/RECORD,,
|
|
11
|
+
tdjson-1.8.59.post1.dist-info/licenses/LICENSE,sha256=3jrkn9HjeTzK88qyzmN2AEDvTZiXXi1tpZflpm4o29c,1062
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AYMEN
|
|
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.
|
|
Binary file
|