2017-09-27 22:06:01 +03:00
|
|
|
import struct
|
|
|
|
|
|
|
|
from . import TLObject
|
2017-09-25 21:52:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
class MessageContainer(TLObject):
|
2017-09-29 14:11:33 +03:00
|
|
|
CONSTRUCTOR_ID = 0x73f1f8dc
|
2017-09-25 21:52:27 +03:00
|
|
|
|
2017-09-27 22:01:20 +03:00
|
|
|
def __init__(self, messages):
|
2017-09-25 21:52:27 +03:00
|
|
|
super().__init__()
|
|
|
|
self.content_related = False
|
2017-09-27 22:01:20 +03:00
|
|
|
self.messages = messages
|
2017-09-25 21:52:27 +03:00
|
|
|
|
2017-09-26 15:36:02 +03:00
|
|
|
def to_bytes(self):
|
2017-09-27 22:06:01 +03:00
|
|
|
return struct.pack(
|
2017-09-29 14:11:33 +03:00
|
|
|
'<Ii', MessageContainer.CONSTRUCTOR_ID, len(self.messages)
|
2017-09-27 22:06:01 +03:00
|
|
|
) + b''.join(m.to_bytes() for m in self.messages)
|
2017-09-25 21:52:27 +03:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def iter_read(reader):
|
|
|
|
reader.read_int(signed=False) # code
|
|
|
|
size = reader.read_int()
|
|
|
|
for _ in range(size):
|
|
|
|
inner_msg_id = reader.read_long()
|
|
|
|
inner_sequence = reader.read_int()
|
|
|
|
inner_length = reader.read_int()
|
|
|
|
yield inner_msg_id, inner_sequence, inner_length
|