tdesktop-tdclient 0.1.0__py3-none-win_amd64.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.
- tdclient/__init__.py +135 -0
- tdclient/_bin/README.md +51 -0
- tdclient/_bin/TelegramHeadless.exe +0 -0
- tdclient/client.py +1684 -0
- tdclient/compat/__init__.py +142 -0
- tdclient/compat/naming.py +139 -0
- tdclient/compat/opentele/__init__.py +14 -0
- tdclient/compat/opentele/api.py +93 -0
- tdclient/compat/opentele/tl.py +31 -0
- tdclient/compat/telethon/__init__.py +60 -0
- tdclient/compat/telethon/client.py +548 -0
- tdclient/compat/telethon/errors.py +235 -0
- tdclient/compat/telethon/helpers.py +84 -0
- tdclient/compat/telethon/message.py +203 -0
- tdclient/compat/telethon/naming.py +31 -0
- tdclient/compat/telethon/tdata.py +465 -0
- tdclient/compat/telethon/tl/__init__.py +45 -0
- tdclient/compat/telethon/tl/functions.py +43 -0
- tdclient/compat/telethon/tl/types.py +41 -0
- tdclient/compat/tl_namespaces.py +131 -0
- tdclient/engine.py +449 -0
- tdclient/entities.py +623 -0
- tdclient/errors.py +348 -0
- tdclient/events/__init__.py +58 -0
- tdclient/events/builder.py +494 -0
- tdclient/events/common.py +416 -0
- tdclient/events/filters.py +327 -0
- tdclient/files.py +566 -0
- tdclient/models.py +174 -0
- tdclient/schema/tl_schema.json +44715 -0
- tdclient/session.py +530 -0
- tdclient/tl/__init__.py +70 -0
- tdclient/tl/builtins.py +213 -0
- tdclient/tl/reader.py +144 -0
- tdclient/tl/registry.py +286 -0
- tdclient/tl/writer.py +217 -0
- tdclient/transport.py +545 -0
- tdclient/utils.py +546 -0
- tdesktop_tdclient-0.1.0.dist-info/METADATA +584 -0
- tdesktop_tdclient-0.1.0.dist-info/RECORD +42 -0
- tdesktop_tdclient-0.1.0.dist-info/WHEEL +5 -0
- tdesktop_tdclient-0.1.0.dist-info/top_level.txt +1 -0
tdclient/__init__.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""tdclient - a Telethon-style asyncio client for the tdesktop headless engine.
|
|
2
|
+
|
|
3
|
+
The MTProto work is done by a bundled ``TelegramHeadless.exe`` built from the
|
|
4
|
+
Telegram Desktop sources; this package speaks TL over a loopback socket and
|
|
5
|
+
wraps it in an async, Telethon-shaped API.
|
|
6
|
+
|
|
7
|
+
>>> import asyncio
|
|
8
|
+
>>> from tdclient import Client, tl
|
|
9
|
+
>>>
|
|
10
|
+
>>> async def main():
|
|
11
|
+
... async with Client(tdata=r"D:/build/tdata") as client:
|
|
12
|
+
... me = await client.get_me()
|
|
13
|
+
... print(me.first_name, me.username)
|
|
14
|
+
... config = await client(tl.functions.help.getConfig())
|
|
15
|
+
... print(config.this_dc, len(config.dc_options))
|
|
16
|
+
>>>
|
|
17
|
+
>>> asyncio.run(main())
|
|
18
|
+
|
|
19
|
+
Layering, bottom to top:
|
|
20
|
+
|
|
21
|
+
``tdclient.tl``
|
|
22
|
+
The TL binary layer - schema, generated classes, encode/decode.
|
|
23
|
+
``tdclient.transport``
|
|
24
|
+
Byte-level link to the engine (loopback TCP, or a named pipe).
|
|
25
|
+
``tdclient.session``
|
|
26
|
+
JSONL framing, request correlation, update dispatch.
|
|
27
|
+
``tdclient.engine``
|
|
28
|
+
Locating, launching and stopping the engine process.
|
|
29
|
+
``tdclient.events``
|
|
30
|
+
Event objects, the container decoder, and filters.
|
|
31
|
+
``tdclient.client``
|
|
32
|
+
The user-facing async API.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
from . import events, files, tl, utils
|
|
38
|
+
from .client import Client
|
|
39
|
+
from .engine import EngineProcess, find_engine_binary, wait_self_ready
|
|
40
|
+
from .entities import EntityCache, EntityNotFoundError
|
|
41
|
+
from .errors import (
|
|
42
|
+
BadRequestError,
|
|
43
|
+
ConnectionClosedError,
|
|
44
|
+
EngineCrashedError,
|
|
45
|
+
EngineNotFoundError,
|
|
46
|
+
EngineNotReadyError,
|
|
47
|
+
EngineProtocolError,
|
|
48
|
+
EngineStartupError,
|
|
49
|
+
FloodWaitError,
|
|
50
|
+
ForbiddenError,
|
|
51
|
+
InternalServerError,
|
|
52
|
+
MigrateError,
|
|
53
|
+
NotFoundError,
|
|
54
|
+
RequestTimeoutError,
|
|
55
|
+
RPCError,
|
|
56
|
+
TdClientError,
|
|
57
|
+
TransportError,
|
|
58
|
+
UnauthorizedError,
|
|
59
|
+
)
|
|
60
|
+
from .events import (
|
|
61
|
+
Event,
|
|
62
|
+
MessageDeleted,
|
|
63
|
+
MessageEdited,
|
|
64
|
+
MessageEvent,
|
|
65
|
+
MessageRead,
|
|
66
|
+
NewMessage,
|
|
67
|
+
Raw,
|
|
68
|
+
UpdateState,
|
|
69
|
+
UserUpdate,
|
|
70
|
+
)
|
|
71
|
+
from .events import filters
|
|
72
|
+
from .files import FileDescriptor, FileError
|
|
73
|
+
from .models import Dialog, Dialogs
|
|
74
|
+
from .session import PendingInvocation, Session
|
|
75
|
+
from .transport import (
|
|
76
|
+
NamedPipeTransport,
|
|
77
|
+
TcpTransport,
|
|
78
|
+
Transport,
|
|
79
|
+
UnixSocketTransport,
|
|
80
|
+
create_transport,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
__version__ = "0.1.0"
|
|
84
|
+
|
|
85
|
+
__all__ = [
|
|
86
|
+
"BadRequestError",
|
|
87
|
+
"Client",
|
|
88
|
+
"ConnectionClosedError",
|
|
89
|
+
"Dialog",
|
|
90
|
+
"Dialogs",
|
|
91
|
+
"EngineCrashedError",
|
|
92
|
+
"EngineNotFoundError",
|
|
93
|
+
"EngineNotReadyError",
|
|
94
|
+
"EngineProcess",
|
|
95
|
+
"EngineProtocolError",
|
|
96
|
+
"EngineStartupError",
|
|
97
|
+
"EntityCache",
|
|
98
|
+
"EntityNotFoundError",
|
|
99
|
+
"Event",
|
|
100
|
+
"FileDescriptor",
|
|
101
|
+
"FileError",
|
|
102
|
+
"FloodWaitError",
|
|
103
|
+
"ForbiddenError",
|
|
104
|
+
"InternalServerError",
|
|
105
|
+
"MessageDeleted",
|
|
106
|
+
"MessageEdited",
|
|
107
|
+
"MessageEvent",
|
|
108
|
+
"MessageRead",
|
|
109
|
+
"MigrateError",
|
|
110
|
+
"NamedPipeTransport",
|
|
111
|
+
"NewMessage",
|
|
112
|
+
"NotFoundError",
|
|
113
|
+
"PendingInvocation",
|
|
114
|
+
"RPCError",
|
|
115
|
+
"Raw",
|
|
116
|
+
"RequestTimeoutError",
|
|
117
|
+
"Session",
|
|
118
|
+
"TcpTransport",
|
|
119
|
+
"TdClientError",
|
|
120
|
+
"Transport",
|
|
121
|
+
"TransportError",
|
|
122
|
+
"UnauthorizedError",
|
|
123
|
+
"UnixSocketTransport",
|
|
124
|
+
"UpdateState",
|
|
125
|
+
"UserUpdate",
|
|
126
|
+
"__version__",
|
|
127
|
+
"create_transport",
|
|
128
|
+
"events",
|
|
129
|
+
"files",
|
|
130
|
+
"filters",
|
|
131
|
+
"find_engine_binary",
|
|
132
|
+
"tl",
|
|
133
|
+
"utils",
|
|
134
|
+
"wait_self_ready",
|
|
135
|
+
]
|
tdclient/_bin/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# `_bin` — the engine that ships with the wheel
|
|
2
|
+
|
|
3
|
+
This directory holds the headless MTProto engine: `TelegramHeadless.exe` on
|
|
4
|
+
Windows, `TelegramHeadless` on Linux. It is empty in git apart from this file;
|
|
5
|
+
`build-tools/make-wheel.sh` copies the built executable in here before
|
|
6
|
+
packaging, and `.gitignore` keeps the binaries out of the repository.
|
|
7
|
+
|
|
8
|
+
Only one platform's engine belongs here at a time. The script removes the other
|
|
9
|
+
one first, because `package-data = ["_bin/*"]` would otherwise put both in every
|
|
10
|
+
wheel — the right one plus dead weight for a platform the wheel is not tagged
|
|
11
|
+
for.
|
|
12
|
+
|
|
13
|
+
## Why it is here
|
|
14
|
+
|
|
15
|
+
`find_engine_binary()` looks in this directory *before* it looks for a checkout,
|
|
16
|
+
so an installed `tdclient` is self-contained:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
tdclient/_bin/TelegramHeadless[.exe] <- the installed case, found first
|
|
20
|
+
<repo>/out-release/bin/TelegramHeadless[.exe] <- a developer's build tree
|
|
21
|
+
$TDCLIENT_ENGINE <- always wins, for both
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The name without a suffix is what `engine.py::executable_name()` looks for on
|
|
25
|
+
non-Windows platforms, so the two spellings have to stay in step.
|
|
26
|
+
|
|
27
|
+
Without this step a wheel would install perfectly and then fail at `connect()`
|
|
28
|
+
with "could not find the headless engine", which is a confusing way to learn that
|
|
29
|
+
the package and the engine have to travel together.
|
|
30
|
+
|
|
31
|
+
## The engine travels alone
|
|
32
|
+
|
|
33
|
+
It imports only libraries the operating system itself provides — on Windows no
|
|
34
|
+
Qt, no OpenSSL, no VC runtime; on Linux no `libQt5Core.so.5`, no `libssl.so.3`.
|
|
35
|
+
That is what makes a single-file copy sufficient, and it is verified rather than
|
|
36
|
+
assumed:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
python build-tools/check-engine-deps.py python/tdclient/_bin/TelegramHeadless
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If a future build switches any of those to shared libraries, that check fails
|
|
43
|
+
and names the library that needs to be copied alongside.
|
|
44
|
+
|
|
45
|
+
## Building the wheel
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
build-tools/build.sh # produce the engine
|
|
49
|
+
build-tools/make-wheel.sh # stage it here, then build the wheel
|
|
50
|
+
pip install python/dist/tdesktop_tdclient-*.whl
|
|
51
|
+
```
|
|
Binary file
|