Fix client method calls and reading TLObjects

This commit is contained in:
Lonami Exo
2021-09-12 15:46:57 +02:00
parent c84043cf71
commit e9b97b5e4a
5 changed files with 81 additions and 63 deletions

View File

@@ -9,6 +9,8 @@ from struct import unpack
from ..errors import TypeNotFoundError
from .. import _tl
from .._tl.alltlobjects import tlobjects
from .._tl import core
_EPOCH_NAIVE = datetime(*time.gmtime(0)[:6])
_EPOCH = _EPOCH_NAIVE.replace(tzinfo=timezone.utc)
@@ -117,7 +119,7 @@ class BinaryReader:
def tgread_object(self):
"""Reads a Telegram object."""
constructor_id = self.read_int(signed=False)
clazz = _tl.tlobjects.get(constructor_id, None)
clazz = tlobjects.get(constructor_id, None)
if clazz is None:
# The class was None, but there's still a
# chance of it being a manually parsed value like bool!
@@ -129,7 +131,7 @@ class BinaryReader:
elif value == 0x1cb5c415: # Vector
return [self.tgread_object() for _ in range(self.read_int())]
clazz = _tl.core.get(constructor_id, None)
clazz = core.core_objects.get(constructor_id, None)
if clazz is None:
# If there was still no luck, give up
self.seek(-4) # Go back