Telethon/telethon/tl/tl_message.py
Andrey Egorov 8057cea294 Fix resending requests on bad salt/msg notification (#369)
These responses from the server could indicate container IDs,
which weren't being saved. This fix also accounts for that case.
2017-10-22 13:13:49 +02:00

23 lines
751 B
Python

import struct
from . import TLObject, GzipPacked
class TLMessage(TLObject):
"""https://core.telegram.org/mtproto/service_messages#simple-container"""
def __init__(self, session, request):
super().__init__()
del self.content_related
self.msg_id = session.get_new_msg_id()
self.seq_no = session.generate_sequence(request.content_related)
self.request = request
self.container_msg_id = None
def __bytes__(self):
body = GzipPacked.gzip_if_smaller(self.request)
return struct.pack('<qii', self.msg_id, self.seq_no, len(body)) + body
def __str__(self):
return 'TLMessage(msg_id={}, seq_no={}, body={})'\
.format(self.msg_id, self.seq_no, self.request)