mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Create a common message base class
This commit is contained in:
@@ -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).
|
||||
"""
|
||||
|
Reference in New Issue
Block a user