mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-26 09:14:31 +03:00
parent
b475a2ecc6
commit
a955138021
|
@ -7,10 +7,23 @@ from ..crypto import AES
|
||||||
from ..errors import SecurityError, InvalidBufferError
|
from ..errors import SecurityError, InvalidBufferError
|
||||||
from ..extensions import BinaryReader
|
from ..extensions import BinaryReader
|
||||||
from ..tl.core import TLMessage
|
from ..tl.core import TLMessage
|
||||||
|
from ..tl.tlobject import TLRequest
|
||||||
from ..tl.functions import InvokeAfterMsgRequest
|
from ..tl.functions import InvokeAfterMsgRequest
|
||||||
from ..tl.core.gzippacked import GzipPacked
|
from ..tl.core.gzippacked import GzipPacked
|
||||||
|
|
||||||
|
|
||||||
|
class _OpaqueRequest(TLRequest):
|
||||||
|
"""
|
||||||
|
Wraps a serialized request into a type that can be serialized again.
|
||||||
|
"""
|
||||||
|
def __init__(self, data: bytes):
|
||||||
|
self.data = data
|
||||||
|
|
||||||
|
def _bytes(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MTProtoState:
|
class MTProtoState:
|
||||||
"""
|
"""
|
||||||
`telethon.network.mtprotosender.MTProtoSender` needs to hold a state
|
`telethon.network.mtprotosender.MTProtoSender` needs to hold a state
|
||||||
|
@ -87,8 +100,10 @@ class MTProtoState:
|
||||||
if after_id is None:
|
if after_id is None:
|
||||||
body = GzipPacked.gzip_if_smaller(content_related, data)
|
body = GzipPacked.gzip_if_smaller(content_related, data)
|
||||||
else:
|
else:
|
||||||
|
# The `RequestState` stores `bytes(request)`, not the request itself.
|
||||||
|
# `invokeAfterMsg` wants a `TLRequest` though, hence the wrapping.
|
||||||
body = GzipPacked.gzip_if_smaller(content_related,
|
body = GzipPacked.gzip_if_smaller(content_related,
|
||||||
bytes(InvokeAfterMsgRequest(after_id, data)))
|
bytes(InvokeAfterMsgRequest(after_id, _OpaqueRequest(data))))
|
||||||
|
|
||||||
buffer.write(struct.pack('<qii', msg_id, seq_no, len(body)))
|
buffer.write(struct.pack('<qii', msg_id, seq_no, len(body)))
|
||||||
buffer.write(body)
|
buffer.write(body)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user