From 77a192e0a830ca14f2205570240ff42e7b37c1b5 Mon Sep 17 00:00:00 2001 From: Anton Grigoryev Date: Tue, 24 Mar 2015 08:49:27 +0300 Subject: [PATCH] Naive TL message container implementation --- TL.py | 28 ++++++++++++++++++++++------ mtproto.py | 53 ++++++++++++++++++++++------------------------------- testing.py | 3 ++- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/TL.py b/TL.py index 385764d8..090c0639 100644 --- a/TL.py +++ b/TL.py @@ -16,6 +16,12 @@ class TlConstructor: if param['type'] == "Vector": param['type'] = "Vector t" param['subtype'] = "long" + elif param['type'] == "vector<%Message>": + param['type'] = "vector" + param['subtype'] = "message" + elif param['type'] == "vector": + param['type'] = "vector" + param['subtype'] = "future_salt" else: param['subtype'] = None self.params.append(param) @@ -56,7 +62,8 @@ class TL: tl = TL(os.path.join(os.path.dirname(__file__), "TL_schema.JSON")) -def serialize_obj(bytes_io, type_, **kwargs): +def serialize_obj(type_, **kwargs): + bytes_io = io.BytesIO() try: tl_constructor = tl.constructor_type[type_] except KeyError: @@ -64,9 +71,11 @@ def serialize_obj(bytes_io, type_, **kwargs): bytes_io.write(struct.pack('