pixelazer-tl 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.
- pixelazer_tl-1.0.0/.gitignore +9 -0
- pixelazer_tl-1.0.0/LICENSE.md +23 -0
- pixelazer_tl-1.0.0/NOTICE.md +7 -0
- pixelazer_tl-1.0.0/PKG-INFO +62 -0
- pixelazer_tl-1.0.0/README.md +36 -0
- pixelazer_tl-1.0.0/hatch_build.py +133 -0
- pixelazer_tl-1.0.0/pixelazertl/__init__.py +19 -0
- pixelazer_tl-1.0.0/pixelazertl/_security.py +13 -0
- pixelazer_tl-1.0.0/pixelazertl/_updates/__init__.py +3 -0
- pixelazer_tl-1.0.0/pixelazertl/_updates/entitycache.py +72 -0
- pixelazer_tl-1.0.0/pixelazertl/_updates/messagebox.py +954 -0
- pixelazer_tl-1.0.0/pixelazertl/_updates/session.py +200 -0
- pixelazer_tl-1.0.0/pixelazertl/_web.py +66 -0
- pixelazer_tl-1.0.0/pixelazertl/client/__init__.py +27 -0
- pixelazer_tl-1.0.0/pixelazertl/client/account.py +247 -0
- pixelazer_tl-1.0.0/pixelazertl/client/auth.py +714 -0
- pixelazer_tl-1.0.0/pixelazertl/client/bots.py +75 -0
- pixelazer_tl-1.0.0/pixelazertl/client/buttons.py +104 -0
- pixelazer_tl-1.0.0/pixelazertl/client/chats.py +1406 -0
- pixelazer_tl-1.0.0/pixelazertl/client/dialogs.py +632 -0
- pixelazer_tl-1.0.0/pixelazertl/client/downloads.py +1162 -0
- pixelazer_tl-1.0.0/pixelazertl/client/help.py +82 -0
- pixelazer_tl-1.0.0/pixelazertl/client/messageparse.py +249 -0
- pixelazer_tl-1.0.0/pixelazertl/client/messages.py +1768 -0
- pixelazer_tl-1.0.0/pixelazertl/client/payments.py +124 -0
- pixelazer_tl-1.0.0/pixelazertl/client/telegrambaseclient.py +1048 -0
- pixelazer_tl-1.0.0/pixelazertl/client/telegramclient.py +35 -0
- pixelazer_tl-1.0.0/pixelazertl/client/updates.py +792 -0
- pixelazer_tl-1.0.0/pixelazertl/client/uploads.py +1188 -0
- pixelazer_tl-1.0.0/pixelazertl/client/users.py +723 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/__init__.py +11 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/aes.py +114 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/aesctr.py +44 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/authkey.py +68 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/cdndecrypter.py +110 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/factorization.py +69 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/libssl.py +143 -0
- pixelazer_tl-1.0.0/pixelazertl/crypto/rsa.py +159 -0
- pixelazer_tl-1.0.0/pixelazertl/custom.py +1 -0
- pixelazer_tl-1.0.0/pixelazertl/errors/__init__.py +55 -0
- pixelazer_tl-1.0.0/pixelazertl/errors/common.py +194 -0
- pixelazer_tl-1.0.0/pixelazertl/errors/rpcbaseerrors.py +155 -0
- pixelazer_tl-1.0.0/pixelazertl/events/__init__.py +140 -0
- pixelazer_tl-1.0.0/pixelazertl/events/album.py +356 -0
- pixelazer_tl-1.0.0/pixelazertl/events/callbackquery.py +365 -0
- pixelazer_tl-1.0.0/pixelazertl/events/chataction.py +478 -0
- pixelazer_tl-1.0.0/pixelazertl/events/common.py +191 -0
- pixelazer_tl-1.0.0/pixelazertl/events/inlinequery.py +256 -0
- pixelazer_tl-1.0.0/pixelazertl/events/messagedeleted.py +52 -0
- pixelazer_tl-1.0.0/pixelazertl/events/messageedited.py +54 -0
- pixelazer_tl-1.0.0/pixelazertl/events/messageread.py +147 -0
- pixelazer_tl-1.0.0/pixelazertl/events/newmessage.py +251 -0
- pixelazer_tl-1.0.0/pixelazertl/events/raw.py +54 -0
- pixelazer_tl-1.0.0/pixelazertl/events/userupdate.py +333 -0
- pixelazer_tl-1.0.0/pixelazertl/extensions/__init__.py +7 -0
- pixelazer_tl-1.0.0/pixelazertl/extensions/binaryreader.py +210 -0
- pixelazer_tl-1.0.0/pixelazertl/extensions/html.py +440 -0
- pixelazer_tl-1.0.0/pixelazertl/extensions/markdown.py +213 -0
- pixelazer_tl-1.0.0/pixelazertl/extensions/messagepacker.py +117 -0
- pixelazer_tl-1.0.0/pixelazertl/functions.py +1 -0
- pixelazer_tl-1.0.0/pixelazertl/helpers.py +483 -0
- pixelazer_tl-1.0.0/pixelazertl/hints.py +63 -0
- pixelazer_tl-1.0.0/pixelazertl/network/__init__.py +20 -0
- pixelazer_tl-1.0.0/pixelazertl/network/authenticator.py +239 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/__init__.py +12 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/connection.py +452 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/http.py +42 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/tcpabridged.py +35 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/tcpfull.py +65 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/tcpintermediate.py +49 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/tcpmtproxy.py +477 -0
- pixelazer_tl-1.0.0/pixelazertl/network/connection/tcpobfuscated.py +65 -0
- pixelazer_tl-1.0.0/pixelazertl/network/mtprotoplainsender.py +57 -0
- pixelazer_tl-1.0.0/pixelazertl/network/mtprotosender.py +1022 -0
- pixelazer_tl-1.0.0/pixelazertl/network/mtprotostate.py +307 -0
- pixelazer_tl-1.0.0/pixelazertl/network/requeststate.py +23 -0
- pixelazer_tl-1.0.0/pixelazertl/password.py +450 -0
- pixelazer_tl-1.0.0/pixelazertl/requestiter.py +133 -0
- pixelazer_tl-1.0.0/pixelazertl/sessions/__init__.py +4 -0
- pixelazer_tl-1.0.0/pixelazertl/sessions/abstract.py +172 -0
- pixelazer_tl-1.0.0/pixelazertl/sessions/memory.py +278 -0
- pixelazer_tl-1.0.0/pixelazertl/sessions/sqlite.py +428 -0
- pixelazer_tl-1.0.0/pixelazertl/sessions/string.py +67 -0
- pixelazer_tl-1.0.0/pixelazertl/sync.py +98 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/__init__.py +1 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/core/__init__.py +25 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/core/gzippacked.py +58 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/core/messagecontainer.py +74 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/core/rpcresult.py +33 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/core/tlmessage.py +35 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/__init__.py +15 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/adminlogevent.py +529 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/button.py +407 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/chatgetter.py +152 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/conversation.py +554 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/dialog.py +173 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/draft.py +202 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/file.py +153 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/forward.py +54 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/inlinebuilder.py +512 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/inlineresult.py +186 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/inlineresults.py +88 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/inputsizedfile.py +10 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/message.py +1372 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/messagebutton.py +169 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/participantpermissions.py +188 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/qrlogin.py +127 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/sendergetter.py +104 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/custom/stargift.py +473 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/patched/__init__.py +26 -0
- pixelazer_tl-1.0.0/pixelazertl/tl/tlobject.py +519 -0
- pixelazer_tl-1.0.0/pixelazertl/types.py +1 -0
- pixelazer_tl-1.0.0/pixelazertl/utils.py +1755 -0
- pixelazer_tl-1.0.0/pixelazertl/version.py +3 -0
- pixelazer_tl-1.0.0/pyproject.toml +65 -0
- pixelazer_tl-1.0.0/telethon_generator/__init__.py +1 -0
- pixelazer_tl-1.0.0/telethon_generator/data/api.tl +3117 -0
- pixelazer_tl-1.0.0/telethon_generator/data/errors.csv +535 -0
- pixelazer_tl-1.0.0/telethon_generator/data/friendly.csv +26 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/404.html +44 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/core.html +179 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/css/docs.dark.css +185 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/css/docs.h4x0r.css +229 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/css/docs.light.css +182 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/img/arrow.svg +35 -0
- pixelazer_tl-1.0.0/telethon_generator/data/html/js/search.js +244 -0
- pixelazer_tl-1.0.0/telethon_generator/data/methods.csv +365 -0
- pixelazer_tl-1.0.0/telethon_generator/data/mtproto.tl +116 -0
- pixelazer_tl-1.0.0/telethon_generator/docswriter.py +292 -0
- pixelazer_tl-1.0.0/telethon_generator/generators/__init__.py +3 -0
- pixelazer_tl-1.0.0/telethon_generator/generators/docs.py +705 -0
- pixelazer_tl-1.0.0/telethon_generator/generators/errors.py +68 -0
- pixelazer_tl-1.0.0/telethon_generator/generators/tlobject.py +750 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/__init__.py +3 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/errors.py +95 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/methods.py +73 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/tlobject/__init__.py +3 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/tlobject/parser.py +140 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/tlobject/tlarg.py +258 -0
- pixelazer_tl-1.0.0/telethon_generator/parsers/tlobject/tlobject.py +160 -0
- pixelazer_tl-1.0.0/telethon_generator/sourcebuilder.py +65 -0
- pixelazer_tl-1.0.0/telethon_generator/syncerrors.py +69 -0
- pixelazer_tl-1.0.0/telethon_generator/utils.py +8 -0
- pixelazer_tl-1.0.0/tests/test_security.py +157 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-Present LonamiWebs
|
|
4
|
+
Copyright (c) 2026 - 2030 Codrago
|
|
5
|
+
Copyright (c) 2026 LowSense — astralix-tl modifications
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Origins and modifications
|
|
2
|
+
|
|
3
|
+
astralix-tl is based on HerokuTL 2.2.0.dev2, obtained from https://github.com/sepiol026-wq/herokutl-sources at commit 2537d6f5bff7b86f99b074ce2db967f788ede093. HerokuTL is derived from Telethon (https://codeberg.org/Lonami/Telethon).
|
|
4
|
+
|
|
5
|
+
Original copyright and MIT terms are preserved in LICENSE.md and source headers. Copyright (c) 2026 LowSense applies to the astralix modifications only. Changes include the import/distribution rename and security hardening described in README.md. The local version is 1.0.0.
|
|
6
|
+
|
|
7
|
+
Telethon v1 uses MIT: https://codeberg.org/Lonami/Telethon/src/branch/v1/LICENSE . Its original copyright (c) 2016-Present LonamiWebs has been restored in LICENSE.md; the intermediate HerokuTL source archive omitted that line.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pixelazer-tl
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: This library is built for the Pixelazer Userbot and is based on Telethon.
|
|
5
|
+
Project-URL: Homepage, https://github.com/gardenyab/pixelazer-tl
|
|
6
|
+
Project-URL: Source, https://github.com/gardenyab/pixelazer-tl
|
|
7
|
+
Project-URL: Documentation, https://docs.telethon.dev
|
|
8
|
+
Project-URL: Reference, https://tl.telethon.dev
|
|
9
|
+
Author-email: GardenYab <gardenyab@eblanka.com>
|
|
10
|
+
Maintainer: lowsense-dev
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE.md
|
|
13
|
+
License-File: NOTICE.md
|
|
14
|
+
Keywords: api,chat,client,library,messaging,mtproto,telegram
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Communications :: Chat
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: bs4==0.0.2
|
|
21
|
+
Requires-Dist: pyaes
|
|
22
|
+
Requires-Dist: rsa
|
|
23
|
+
Provides-Extra: cryptg
|
|
24
|
+
Requires-Dist: cryptg; extra == 'cryptg'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# astralix-tl
|
|
28
|
+
|
|
29
|
+
Telegram MTProto client library for **astralix Userbot**, based on HerokuTL and Telethon.
|
|
30
|
+
|
|
31
|
+
Repository: https://github.com/lowsense-dev/astralix-tl (private). No project Telegram channels or chats.
|
|
32
|
+
|
|
33
|
+
## Install from source
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uv venv .venv
|
|
37
|
+
uv pip install --python .venv/bin/python .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The distribution is named `astralix-tl`; Python imports use `astralixtl`:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from astralixtl import TelegramClient
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The build generates Telegram types from the included schemas. Build a wheel with `uv build --wheel`.
|
|
47
|
+
|
|
48
|
+
## Security changes
|
|
49
|
+
|
|
50
|
+
This fork bounds packet lengths and gzip output, validates MTProto framing and DH responses with checks active under Python optimization, restricts web downloads to public HTTP(S) endpoints with TLS verification and size/time limits, hardens session-file permissions, and inspects renamed session uploads without optional dependencies.
|
|
51
|
+
|
|
52
|
+
These changes have regression tests in `tests/test_security.py`. They are a targeted review, not a guarantee that all vulnerabilities have been found. New DH primes and downloads above the configured limits require review. Live Telegram login has not been tested in this revision.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv pip install --python .venv/bin/python aiohttp
|
|
56
|
+
.venv/bin/python -I -m unittest discover -s tests -v
|
|
57
|
+
.venv/bin/python -I -O -m unittest discover -s tests -v
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License and origins
|
|
61
|
+
|
|
62
|
+
MIT; see [LICENSE.md](LICENSE.md). Copyright notices for the upstream code and astralix modifications are retained. See [NOTICE.md](NOTICE.md).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# astralix-tl
|
|
2
|
+
|
|
3
|
+
Telegram MTProto client library for **astralix Userbot**, based on HerokuTL and Telethon.
|
|
4
|
+
|
|
5
|
+
Repository: https://github.com/lowsense-dev/astralix-tl (private). No project Telegram channels or chats.
|
|
6
|
+
|
|
7
|
+
## Install from source
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv venv .venv
|
|
11
|
+
uv pip install --python .venv/bin/python .
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The distribution is named `astralix-tl`; Python imports use `astralixtl`:
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from astralixtl import TelegramClient
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The build generates Telegram types from the included schemas. Build a wheel with `uv build --wheel`.
|
|
21
|
+
|
|
22
|
+
## Security changes
|
|
23
|
+
|
|
24
|
+
This fork bounds packet lengths and gzip output, validates MTProto framing and DH responses with checks active under Python optimization, restricts web downloads to public HTTP(S) endpoints with TLS verification and size/time limits, hardens session-file permissions, and inspects renamed session uploads without optional dependencies.
|
|
25
|
+
|
|
26
|
+
These changes have regression tests in `tests/test_security.py`. They are a targeted review, not a guarantee that all vulnerabilities have been found. New DH primes and downloads above the configured limits require review. Live Telegram login has not been tested in this revision.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv pip install --python .venv/bin/python aiohttp
|
|
30
|
+
.venv/bin/python -I -m unittest discover -s tests -v
|
|
31
|
+
.venv/bin/python -I -O -m unittest discover -s tests -v
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## License and origins
|
|
35
|
+
|
|
36
|
+
MIT; see [LICENSE.md](LICENSE.md). Copyright notices for the upstream code and astralix modifications are retained. See [NOTICE.md](NOTICE.md).
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Custom Hatch build hook to generate Python from .tl definitions."""
|
|
2
|
+
|
|
3
|
+
import itertools
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
_BuildHookInterface: Any
|
|
10
|
+
try:
|
|
11
|
+
from hatchling.builders.hooks.plugin.interface import (
|
|
12
|
+
BuildHookInterface as _BuildHookInterface,
|
|
13
|
+
)
|
|
14
|
+
except ImportError:
|
|
15
|
+
|
|
16
|
+
class _FallbackBuildHookInterface:
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
_BuildHookInterface = _FallbackBuildHookInterface
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
BuildHookInterface: Any = _BuildHookInterface
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Needed since we're importing local files
|
|
26
|
+
GENERATOR_DIR = Path("telethon_generator")
|
|
27
|
+
LIBRARY_DIR = Path("astralixtl")
|
|
28
|
+
|
|
29
|
+
ERRORS_IN = GENERATOR_DIR / "data/errors.csv"
|
|
30
|
+
ERRORS_OUT = LIBRARY_DIR / "errors/rpcerrorlist.py"
|
|
31
|
+
|
|
32
|
+
METHODS_IN = GENERATOR_DIR / "data/methods.csv"
|
|
33
|
+
|
|
34
|
+
# Which raw API methods are covered by *friendly* methods in the client?
|
|
35
|
+
FRIENDLY_IN = GENERATOR_DIR / "data/friendly.csv"
|
|
36
|
+
|
|
37
|
+
TLOBJECT_IN_TLS = [Path(x) for x in GENERATOR_DIR.glob("data/*.tl")]
|
|
38
|
+
TLOBJECT_OUT = LIBRARY_DIR / "tl"
|
|
39
|
+
IMPORT_DEPTH = 2
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class CustomBuildHook(BuildHookInterface):
|
|
43
|
+
def _root(self) -> Path:
|
|
44
|
+
return Path(self.root)
|
|
45
|
+
|
|
46
|
+
def _build_dir(self) -> Path:
|
|
47
|
+
return Path(self.directory)
|
|
48
|
+
|
|
49
|
+
def _clean_generated_artifacts(self) -> None:
|
|
50
|
+
build_dir = self._build_dir().resolve()
|
|
51
|
+
root = self._root().resolve()
|
|
52
|
+
generated_package = build_dir / LIBRARY_DIR
|
|
53
|
+
|
|
54
|
+
if build_dir == root:
|
|
55
|
+
clean_tl_dir = root / TLOBJECT_OUT
|
|
56
|
+
clean_errors_file = root / ERRORS_OUT
|
|
57
|
+
else:
|
|
58
|
+
clean_tl_dir = generated_package / "tl"
|
|
59
|
+
clean_errors_file = generated_package / "errors/rpcerrorlist.py"
|
|
60
|
+
|
|
61
|
+
from telethon_generator.generators import clean_tlobjects
|
|
62
|
+
|
|
63
|
+
clean_tlobjects(clean_tl_dir)
|
|
64
|
+
if clean_errors_file.is_file():
|
|
65
|
+
clean_errors_file.unlink()
|
|
66
|
+
|
|
67
|
+
if build_dir != root and generated_package.is_dir():
|
|
68
|
+
shutil.rmtree(generated_package)
|
|
69
|
+
|
|
70
|
+
def clean(self, versions: list[str]) -> None:
|
|
71
|
+
if self.root not in sys.path:
|
|
72
|
+
sys.path.insert(0, self.root)
|
|
73
|
+
|
|
74
|
+
self._clean_generated_artifacts()
|
|
75
|
+
|
|
76
|
+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
|
|
77
|
+
if self.root not in sys.path:
|
|
78
|
+
sys.path.insert(0, self.root)
|
|
79
|
+
|
|
80
|
+
self.clean([])
|
|
81
|
+
if self.target_name == "sdist":
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
from telethon_generator.parsers import (
|
|
85
|
+
parse_errors,
|
|
86
|
+
parse_methods,
|
|
87
|
+
parse_tl,
|
|
88
|
+
find_layer,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
from telethon_generator.generators import generate_errors, generate_tlobjects
|
|
92
|
+
|
|
93
|
+
root = self._root()
|
|
94
|
+
build_dir = self._build_dir()
|
|
95
|
+
generated_tl_dir = build_dir / TLOBJECT_OUT
|
|
96
|
+
generated_errors = build_dir / ERRORS_OUT
|
|
97
|
+
|
|
98
|
+
layer = next(filter(None, map(lambda p: find_layer(root / p), TLOBJECT_IN_TLS)))
|
|
99
|
+
errors = list(parse_errors(root / ERRORS_IN))
|
|
100
|
+
methods = list(
|
|
101
|
+
parse_methods(
|
|
102
|
+
root / METHODS_IN,
|
|
103
|
+
root / FRIENDLY_IN,
|
|
104
|
+
{e.str_code: e for e in errors},
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
tlobjects = list(
|
|
109
|
+
itertools.chain(
|
|
110
|
+
*(parse_tl(root / file, layer, methods) for file in TLOBJECT_IN_TLS)
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
generate_tlobjects(tlobjects, layer, IMPORT_DEPTH, generated_tl_dir)
|
|
115
|
+
generated_errors.parent.mkdir(parents=True, exist_ok=True)
|
|
116
|
+
with generated_errors.open("w") as file:
|
|
117
|
+
generate_errors(errors, file)
|
|
118
|
+
|
|
119
|
+
build_data["force_include"][str(generated_tl_dir / "functions")] = str(
|
|
120
|
+
TLOBJECT_OUT / "functions"
|
|
121
|
+
)
|
|
122
|
+
build_data["force_include"][str(generated_tl_dir / "types")] = str(
|
|
123
|
+
TLOBJECT_OUT / "types"
|
|
124
|
+
)
|
|
125
|
+
build_data["force_include"][str(generated_tl_dir / "alltlobjects.py")] = str(
|
|
126
|
+
TLOBJECT_OUT / "alltlobjects.py"
|
|
127
|
+
)
|
|
128
|
+
build_data["force_include"][str(generated_errors)] = str(ERRORS_OUT)
|
|
129
|
+
|
|
130
|
+
def finalize(
|
|
131
|
+
self, version: str, build_data: dict[str, Any], artifact_path: str
|
|
132
|
+
) -> None:
|
|
133
|
+
self.clean([])
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .client.telegramclient import TelegramClient
|
|
2
|
+
from .network import connection
|
|
3
|
+
from .tl.custom import Button
|
|
4
|
+
from .tl import patched as _ # import for its side-effects
|
|
5
|
+
from . import version, events, utils, errors, types, functions, custom
|
|
6
|
+
|
|
7
|
+
__version__ = version.__version__
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"TelegramClient",
|
|
11
|
+
"Button",
|
|
12
|
+
"types",
|
|
13
|
+
"functions",
|
|
14
|
+
"custom",
|
|
15
|
+
"errors",
|
|
16
|
+
"events",
|
|
17
|
+
"utils",
|
|
18
|
+
"connection",
|
|
19
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Limits and validation for data received from remote peers."""
|
|
2
|
+
|
|
3
|
+
MAX_PACKET_SIZE = 16 * 1024 * 1024
|
|
4
|
+
MAX_UNCOMPRESSED_SIZE = 16 * 1024 * 1024
|
|
5
|
+
MAX_WEB_DOCUMENT_SIZE = 256 * 1024 * 1024
|
|
6
|
+
|
|
7
|
+
TELEGRAM_DH_PRIME = bytes.fromhex("c71caeb9c6b1c9048e6c522f70f13f73980d40238e3e21c14934d037563d930f48198a0aa7c14058229493d22530f4dbfa336f6e0ac925139543aed44cce7c3720fd51f69458705ac68cd4fe6b6b13abdc9746512969328454f18faf8c595f642477fe96bb2a941d5bcd1d4ac8cc49880708fa9b378e3c4f3a9060bee67cf9a4a4a695811051907e162753b56b0f6b410dba74d8a84b2a14b3144e0ef1284754fd17ed950d5965b4b9dd46582db1178d169c6bc465b0d6ff9ca3928fef5b9ae4e418fc15e83ebea0f87fa9ff5eed70050ded2849f47bf959d956850ce929851f0d8115f635b105ee2e4e15d04b2454bf6f4fadf034b10403119cd8e3b92fcc5b")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def validate_packet_length(length, minimum=4):
|
|
11
|
+
if not minimum <= length <= MAX_PACKET_SIZE:
|
|
12
|
+
raise ValueError("Invalid or oversized MTProto packet length")
|
|
13
|
+
return length
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from .session import EntityType, Entity
|
|
2
|
+
from ..tl import types
|
|
3
|
+
|
|
4
|
+
_sentinel = object()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class EntityCache:
|
|
8
|
+
def __init__(
|
|
9
|
+
self, hash_map: dict = _sentinel, self_id: int = None, self_bot: bool = None
|
|
10
|
+
):
|
|
11
|
+
self.hash_map = {} if hash_map is _sentinel else hash_map
|
|
12
|
+
self.self_id = self_id
|
|
13
|
+
self.self_bot = self_bot
|
|
14
|
+
|
|
15
|
+
def set_self_user(self, id, bot, hash):
|
|
16
|
+
self.self_id = id
|
|
17
|
+
self.self_bot = bot
|
|
18
|
+
if hash:
|
|
19
|
+
self.hash_map[id] = (hash, EntityType.BOT if bot else EntityType.USER)
|
|
20
|
+
|
|
21
|
+
def get(self, id):
|
|
22
|
+
try:
|
|
23
|
+
hash, ty = self.hash_map[id]
|
|
24
|
+
return Entity(ty, id, hash)
|
|
25
|
+
except KeyError:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
def extend(self, users, chats):
|
|
29
|
+
# See https://core.telegram.org/api/min for "issues" with "min constructors".
|
|
30
|
+
self.hash_map.update(
|
|
31
|
+
(
|
|
32
|
+
u.id,
|
|
33
|
+
(
|
|
34
|
+
u.access_hash,
|
|
35
|
+
EntityType.BOT if u.bot else EntityType.USER,
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
for u in users
|
|
39
|
+
if getattr(u, "access_hash", None) and not u.min
|
|
40
|
+
)
|
|
41
|
+
self.hash_map.update(
|
|
42
|
+
(
|
|
43
|
+
c.id,
|
|
44
|
+
(
|
|
45
|
+
c.access_hash,
|
|
46
|
+
(
|
|
47
|
+
EntityType.COMMUNITY
|
|
48
|
+
if isinstance(c, types.Community)
|
|
49
|
+
else (
|
|
50
|
+
EntityType.MEGAGROUP
|
|
51
|
+
if getattr(c, "megagroup", None)
|
|
52
|
+
else (
|
|
53
|
+
EntityType.GIGAGROUP
|
|
54
|
+
if getattr(c, "gigagroup", None)
|
|
55
|
+
else EntityType.CHANNEL
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
for c in chats
|
|
62
|
+
if getattr(c, "access_hash", None) and not getattr(c, "min", None)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def put(self, entity):
|
|
66
|
+
self.hash_map[entity.id] = (entity.hash, entity.ty)
|
|
67
|
+
|
|
68
|
+
def retain(self, filter):
|
|
69
|
+
self.hash_map = {k: v for k, v in self.hash_map.items() if filter(k)}
|
|
70
|
+
|
|
71
|
+
def __len__(self):
|
|
72
|
+
return len(self.hash_map)
|