wintergram-userbot 1.3__tar.gz → 1.4__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.
- {wintergram_userbot-1.3/wintergram_userbot.egg-info → wintergram_userbot-1.4}/PKG-INFO +1 -1
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/pyproject.toml +1 -1
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/__init__.py +1 -1
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/network/mtproto.py +45 -3
- {wintergram_userbot-1.3 → wintergram_userbot-1.4/wintergram_userbot.egg-info}/PKG-INFO +1 -1
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/MANIFEST.in +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/README.md +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/setup.cfg +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/api/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/api/functions.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/api/updates.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/client.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/aes.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/auth_key.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/dh.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/rsa.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/crypto/srp.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/errors.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/network/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/network/connection.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/network/transport.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/session/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/session/session.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/session/storage.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schema_resolver.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/__init__.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/core.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/latest.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v113.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v119.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v128.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v133.json +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/serializer.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/types.py +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot.egg-info/SOURCES.txt +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot.egg-info/dependency_links.txt +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot.egg-info/requires.txt +0 -0
- {wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot.egg-info/top_level.txt +0 -0
|
@@ -67,6 +67,21 @@ ID_PONG = 0x347773C5
|
|
|
67
67
|
ID_GZIP_PACKED = 0x3072CFA1
|
|
68
68
|
ID_PING = 0x7ABE77EC
|
|
69
69
|
|
|
70
|
+
# little-endian сигнатура gzip_packed в начале тела ответа
|
|
71
|
+
GZIP_MAGIC_LE = struct.pack("<I", ID_GZIP_PACKED)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def inflate(data: bytes) -> bytes:
|
|
75
|
+
"""Распаковывает gzip/zlib/deflate - сервер встречается со всеми тремя."""
|
|
76
|
+
if not data:
|
|
77
|
+
raise ValueError("empty packed payload")
|
|
78
|
+
for wbits in (16 + zlib.MAX_WBITS, zlib.MAX_WBITS, -zlib.MAX_WBITS):
|
|
79
|
+
try:
|
|
80
|
+
return zlib.decompress(data, wbits)
|
|
81
|
+
except zlib.error:
|
|
82
|
+
continue
|
|
83
|
+
raise ValueError("cannot inflate %d bytes" % len(data))
|
|
84
|
+
|
|
70
85
|
# якоря эр (по убыванию) для определения layer
|
|
71
86
|
ERA_ORDER = (228, 202, 198, 181, 167)
|
|
72
87
|
|
|
@@ -309,7 +324,33 @@ class MTProtoConnection:
|
|
|
309
324
|
desc = self._schema.by_id(ident)
|
|
310
325
|
if desc is None:
|
|
311
326
|
raise TLParseError("unknown constructor 0x%08x" % ident)
|
|
312
|
-
return decode_constructor(r, desc, self._schema)
|
|
327
|
+
return self.unpack_object(decode_constructor(r, desc, self._schema))
|
|
328
|
+
|
|
329
|
+
@staticmethod
|
|
330
|
+
def _is_gzip(obj) -> bool:
|
|
331
|
+
if not isinstance(obj, dict):
|
|
332
|
+
return False
|
|
333
|
+
if obj.get("_id") == ID_GZIP_PACKED:
|
|
334
|
+
return True
|
|
335
|
+
return str(obj.get("_", "")).lower() == "gzip_packed"
|
|
336
|
+
|
|
337
|
+
def unpack_object(self, obj, depth=0):
|
|
338
|
+
"""Распаковывает gzip_packed и декодирует то, что внутри.
|
|
339
|
+
|
|
340
|
+
Сервер заворачивает крупные ответы (messages.getDialogs и др.)
|
|
341
|
+
в gzip_packed: он приходит полем result у rpc_result, поэтому
|
|
342
|
+
проверка по сигнатуре тела ответа его не ловит.
|
|
343
|
+
"""
|
|
344
|
+
while depth < 4 and self._is_gzip(obj):
|
|
345
|
+
packed = obj.get("packed_data") or obj.get("bytes") or b""
|
|
346
|
+
raw = inflate(packed)
|
|
347
|
+
rr = TLReader(raw)
|
|
348
|
+
desc = self._schema.by_id(rr.read_uint())
|
|
349
|
+
if desc is None:
|
|
350
|
+
raise TLParseError("unknown constructor inside gzip_packed")
|
|
351
|
+
obj = decode_constructor(rr, desc, self._schema)
|
|
352
|
+
depth += 1
|
|
353
|
+
return obj
|
|
313
354
|
|
|
314
355
|
def _handle_rpc_result(self, req_msg_id: int, r: TLReader):
|
|
315
356
|
raw = bytes(r.data[r.pos:])
|
|
@@ -323,10 +364,10 @@ class MTProtoConnection:
|
|
|
323
364
|
self._pending.pop(req_msg_id, None)
|
|
324
365
|
return
|
|
325
366
|
body = raw
|
|
326
|
-
if body[:4] ==
|
|
367
|
+
if body[:4] == GZIP_MAGIC_LE:
|
|
327
368
|
pack_r = TLReader(body)
|
|
328
369
|
pack_r.read_uint()
|
|
329
|
-
body =
|
|
370
|
+
body = inflate(pack_r.read_bytes())
|
|
330
371
|
rr = TLReader(body)
|
|
331
372
|
ident = rr.read_uint()
|
|
332
373
|
if ident == ID_RPC_ERROR:
|
|
@@ -346,6 +387,7 @@ class MTProtoConnection:
|
|
|
346
387
|
return
|
|
347
388
|
try:
|
|
348
389
|
obj = decode_constructor(rr, desc, self._schema)
|
|
390
|
+
obj = self.unpack_object(obj)
|
|
349
391
|
except TLParseError as e:
|
|
350
392
|
fut.set_exception(
|
|
351
393
|
RPCError(0, "parse failed for 0x%08x: %s (raw=%s)" % (ident, e, body.hex()))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/core.json
RENAMED
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/latest.json
RENAMED
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v113.json
RENAMED
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v119.json
RENAMED
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v128.json
RENAMED
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot/tl/schemas/data/v133.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wintergram_userbot-1.3 → wintergram_userbot-1.4}/wintergram_userbot.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|