mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-30 17:59:55 +03:00
Try to fix new custom.Message again
This commit is contained in:
parent
e6375790cd
commit
91a6990f68
|
@ -1105,17 +1105,21 @@ class _Message(ChatGetter, SenderGetter):
|
||||||
|
|
||||||
# endregion Private Methods
|
# endregion Private Methods
|
||||||
|
|
||||||
def _patch(cls):
|
|
||||||
# Create new types (classes) for all messages to combine `_Message` in them.
|
|
||||||
# `_Message` comes first so we get its `__init__`.
|
|
||||||
newtype = type(cls.__name__, (_Message, cls), {})
|
|
||||||
setattr(types, cls.__name__, newtype)
|
|
||||||
# `BinaryReader` directly imports this dictionary, but we're mutating it
|
|
||||||
# in-place, not replacing it, so it works out to deserialize `newtype`.
|
|
||||||
alltlobjects.tlobjects[cls.CONSTRUCTOR_ID] = newtype
|
|
||||||
return newtype
|
|
||||||
|
|
||||||
|
class MessageEmpty(_Message, types.MessageEmpty):
|
||||||
|
pass
|
||||||
|
|
||||||
_patch(types.MessageEmpty)
|
types.MessageEmpty = MessageEmpty
|
||||||
Message = _patch(types.Message)
|
alltlobjects.tlobjects[MessageEmpty.CONSTRUCTOR_ID] = MessageEmpty
|
||||||
_patch(types.MessageService)
|
|
||||||
|
class MessageService(_Message, types.MessageService):
|
||||||
|
pass
|
||||||
|
|
||||||
|
types.MessageService = MessageService
|
||||||
|
alltlobjects.tlobjects[MessageService.CONSTRUCTOR_ID] = MessageService
|
||||||
|
|
||||||
|
class Message(_Message, types.Message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
types.Message = Message
|
||||||
|
alltlobjects.tlobjects[Message.CONSTRUCTOR_ID] = Message
|
||||||
|
|
Loading…
Reference in New Issue
Block a user