From 9a47fdc1ee174c62573aa89b2d505ff1933133b3 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 10 Feb 2021 20:18:29 +0100 Subject: [PATCH] Move Message redefinitions back to patched Fixes #1695. This matches the older behaviour better, although the patched module is now written manually. --- telethon/tl/custom/message.py | 21 +-------------------- telethon/tl/patched/__init__.py | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 7174c78b..a73566c8 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -11,7 +11,7 @@ from ... import utils, errors # TODO Figure out a way to have the code generator error on missing fields # Maybe parsing the init function alone if that's possible. -class _Message(ChatGetter, SenderGetter): +class Message(ChatGetter, SenderGetter, TLObject): """ This custom class aggregates both :tl:`Message` and :tl:`MessageService` to ease accessing their members. @@ -1130,22 +1130,3 @@ class _Message(ChatGetter, SenderGetter): return None # endregion Private Methods - - -class MessageEmpty(_Message, types.MessageEmpty): - pass - -types.MessageEmpty = MessageEmpty -alltlobjects.tlobjects[MessageEmpty.CONSTRUCTOR_ID] = MessageEmpty - -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 diff --git a/telethon/tl/patched/__init__.py b/telethon/tl/patched/__init__.py index 37eeab79..d6aa39c2 100644 --- a/telethon/tl/patched/__init__.py +++ b/telethon/tl/patched/__init__.py @@ -1,2 +1,20 @@ -# Compatibility for people relying on this module -from ..custom.message import MessageEmpty, MessageService, Message +from .. import types, alltlobjects +from ..custom.message import Message as _Message + +class MessageEmpty(_Message, types.MessageEmpty): + pass + +types.MessageEmpty = MessageEmpty +alltlobjects.tlobjects[MessageEmpty.CONSTRUCTOR_ID] = MessageEmpty + +class MessageService(_Message, types.MessageService): + pass + +types.MessageService = MessageService +alltlobjects.tlobjects[MessageService.CONSTRUCTOR_ID] = MessageService + +class _Message(_Message, types.Message): + pass + +Message = _Message +types.Message = Message