Skip to content

Commit

Permalink
Move Message redefinitions back to patched
Browse files Browse the repository at this point in the history
Fixes #1695. This matches the older behaviour better, although the
patched module is now written manually.
  • Loading branch information
Lonami committed Feb 10, 2021
1 parent 23041f3 commit 9a47fdc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
21 changes: 1 addition & 20 deletions telethon/tl/custom/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# 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.
Expand Down Expand Up @@ -1130,22 +1130,3 @@ def _document_by_attribute(self, kind, condition=None):
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
22 changes: 20 additions & 2 deletions telethon/tl/patched/__init__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9a47fdc

Please sign in to comment.