Implement MtProto 2.0 (closes #484, thanks @delivrance!)

Huge shoutout to @delivrance's pyrogram, specially this commit:
pyrogram/pyrogram/commit/42f9a2d6994baaf9ecad590d1ff4d175a8c56454
This commit is contained in:
Lonami Exo
2018-01-06 01:55:11 +01:00
parent c039ba3e16
commit 3eafe18d0b
3 changed files with 75 additions and 41 deletions

View File

@@ -56,8 +56,11 @@ class BinaryReader:
return int.from_bytes(
self.read(bits // 8), byteorder='little', signed=signed)
def read(self, length):
def read(self, length=None):
"""Read the given amount of bytes."""
if length is None:
return self.reader.read()
result = self.reader.read(length)
if len(result) != length:
raise BufferError(