2017-09-27 22:01:20 +03:00
|
|
|
import struct
|
|
|
|
|
|
|
|
from . import TLObject, GzipPacked
|
|
|
|
|
|
|
|
|
2017-09-28 12:59:24 +03:00
|
|
|
class TLMessage(TLObject):
|
2017-09-27 22:01:20 +03:00
|
|
|
"""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
|
|
|
|
|
2017-10-17 20:54:24 +03:00
|
|
|
def __bytes__(self):
|
2017-09-27 22:01:20 +03:00
|
|
|
body = GzipPacked.gzip_if_smaller(self.request)
|
|
|
|
return struct.pack('<qii', self.msg_id, self.seq_no, len(body)) + body
|