mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Added ability to both read and write vectors*
This change affects the BinaryReader and BinaryWriter Note that it only allows to write vectors of **TLObjects**, not any other type
This commit is contained in:
@@ -95,6 +95,17 @@ class BinaryWriter:
|
||||
value = 0 if datetime is None else int(datetime.timestamp())
|
||||
self.write_int(value)
|
||||
|
||||
def tgwrite_object(self, tlobject):
|
||||
"""Writes a Telegram object"""
|
||||
tlobject.on_send(self)
|
||||
|
||||
def tgwrite_vector(self, vector):
|
||||
"""Writes a vector of Telegram objects"""
|
||||
self.write_int(0x1cb5c415, signed=False) # Vector's constructor ID
|
||||
self.write_int(len(vector))
|
||||
for item in vector:
|
||||
self.tgwrite_object(item)
|
||||
|
||||
# endregion
|
||||
|
||||
def flush(self):
|
||||
|
Reference in New Issue
Block a user