mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-13 04:56:35 +03:00
Move MessageContainer.on_send inside its .to_bytes
This commit is contained in:
parent
6df9fc558e
commit
795cb98909
|
@ -14,25 +14,22 @@ class MessageContainer(TLObject):
|
||||||
self.session = session
|
self.session = session
|
||||||
self.requests = requests
|
self.requests = requests
|
||||||
|
|
||||||
def on_send(self, writer):
|
|
||||||
writer.write_int(MessageContainer.constructor_id, signed=False)
|
|
||||||
writer.write_int(len(self.requests))
|
|
||||||
for x in self.requests:
|
|
||||||
x.request_msg_id = self.session.get_new_msg_id()
|
|
||||||
|
|
||||||
writer.write_long(x.request_msg_id)
|
|
||||||
writer.write_int(
|
|
||||||
self.session.generate_sequence(x.content_related)
|
|
||||||
)
|
|
||||||
|
|
||||||
packet = GzipPacked.gzip_if_smaller(x)
|
|
||||||
writer.write_int(len(packet))
|
|
||||||
writer.write(packet)
|
|
||||||
|
|
||||||
def to_bytes(self):
|
def to_bytes(self):
|
||||||
# TODO Change this to delete the on_send from this class
|
# TODO Change this to delete the on_send from this class
|
||||||
with BinaryWriter() as writer:
|
with BinaryWriter() as writer:
|
||||||
self.on_send(writer)
|
writer.write_int(MessageContainer.constructor_id, signed=False)
|
||||||
|
writer.write_int(len(self.requests))
|
||||||
|
for x in self.requests:
|
||||||
|
x.request_msg_id = self.session.get_new_msg_id()
|
||||||
|
|
||||||
|
writer.write_long(x.request_msg_id)
|
||||||
|
writer.write_int(
|
||||||
|
self.session.generate_sequence(x.content_related)
|
||||||
|
)
|
||||||
|
|
||||||
|
packet = GzipPacked.gzip_if_smaller(x)
|
||||||
|
writer.write_int(len(packet))
|
||||||
|
writer.write(packet)
|
||||||
return writer.get_bytes()
|
return writer.get_bytes()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user