From 3b12cc3e51b2f2a0822b79850fac4f6d85658059 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 4 Feb 2022 13:05:27 +0100 Subject: [PATCH] Fix stringify for custom Message --- telethon/_misc/helpers.py | 2 +- telethon/types/_custom/message.py | 36 ------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/telethon/_misc/helpers.py b/telethon/_misc/helpers.py index c6c76b8e..64dabd28 100644 --- a/telethon/_misc/helpers.py +++ b/telethon/_misc/helpers.py @@ -194,7 +194,7 @@ def pretty_print(obj, indent=None, max_depth=float('inf')): if max_depth < 0: return '...' - to_d = getattr(obj, '_to_dict', None) or getattr(obj, 'to_dict', None) + to_d = getattr(obj, 'to_dict', None) if callable(to_d): obj = to_d() diff --git a/telethon/types/_custom/message.py b/telethon/types/_custom/message.py index 17f70a90..42d4aeab 100644 --- a/telethon/types/_custom/message.py +++ b/telethon/types/_custom/message.py @@ -1334,39 +1334,6 @@ class Message(ChatGetter, SenderGetter): def to_dict(self): return self._message.to_dict() - def _to_dict(self): - return { - '_': 'Message', - 'id': self.id, - 'out': self.out, - 'date': self.date, - 'text': self.text, - 'sender': self.sender, - 'chat': self.chat, - 'mentioned': self.mentioned, - 'media_unread': self.media_unread, - 'silent': self.silent, - 'post': self.post, - 'from_scheduled': self.from_scheduled, - 'legacy': self.legacy, - 'edit_hide': self.edit_hide, - 'pinned': self.pinned, - 'forward': self.forward, - 'via_bot': self.via_bot, - 'reply_to': self.reply_to, - 'reply_markup': self.reply_markup, - 'views': self.views, - 'forwards': self.forwards, - 'replies': self.replies, - 'edit_date': self.edit_date, - 'post_author': self.post_author, - 'grouped_id': self.grouped_id, - 'ttl_period': self.ttl_period, - 'action': self.action, - 'media': self.media, - 'action_entities': self.action_entities, - } - def __repr__(self): return helpers.pretty_print(self) @@ -1375,6 +1342,3 @@ class Message(ChatGetter, SenderGetter): def stringify(self): return helpers.pretty_print(self, indent=0) - - -# TODO set md by default if commonmark is installed else nothing