Reuse .on_response/.__str__/.stringify, override iff necessary

This commit is contained in:
Lonami Exo
2018-01-19 12:12:52 +01:00
parent f6d98a61cf
commit 33e50aaee1
3 changed files with 33 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ class TLObject:
def __init__(self):
self.confirm_received = Event()
self.rpc_error = None
self.result = None
# These should be overrode
self.content_related = False # Only requests/functions/queries are
@@ -143,6 +144,16 @@ class TLObject:
raise TypeError('Cannot interpret "{}" as a date.'.format(dt))
# These are nearly always the same for all subclasses
def on_response(self, reader):
self.result = reader.tgread_object()
def __str__(self):
return TLObject.pretty_format(self)
def stringify(self):
return TLObject.pretty_format(self, indent=0)
# These should be overrode
def resolve(self, client, utils):
pass