Create a common message base class

This commit is contained in:
Lonami Exo
2018-07-22 13:26:12 +02:00
parent 5df46f9ed8
commit a3ac6d1645
2 changed files with 155 additions and 2 deletions

View File

@@ -1,8 +1,9 @@
import abc
import struct
from datetime import datetime, date, timedelta
class TLObject:
class TLObject(abc.ABC):
CONSTRUCTOR_ID = None
SUBCLASS_OF_ID = None
@@ -140,18 +141,21 @@ class TLObject:
def stringify(self):
return TLObject.pretty_format(self, indent=0)
@abc.abstractmethod
def to_dict(self):
raise NotImplementedError
@abc.abstractmethod
def __bytes__(self):
raise NotImplementedError
@classmethod
@abc.abstractmethod
def from_reader(cls, reader):
raise NotImplementedError
class TLRequest(TLObject):
class TLRequest(abc.ABC, TLObject):
"""
Represents a content-related `TLObject` (a request that can be sent).
"""