From 32ca805f6be0295f53ff9d4e20c817ad7183e949 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 25 Jun 2019 10:25:21 +0200 Subject: [PATCH] Update message.py --- .../types/messages_and_media/message.py | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 34080d7f..16726a47 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -31,33 +31,27 @@ from ..object import Object from ..update import Update from ..user_and_chats.chat import Chat from ..user_and_chats.user import User -from ...style import utils +from ...style import utils, Markdown, HTML class Str(str): def __init__(self, *args): super().__init__() - self._client = None - self._entities = None + self.entities = None - def init(self, client, entities): - self._client = client - self._entities = entities + def init(self, entities): + self.entities = entities return self - @property - def text(self): - return self - @property def markdown(self): - return self._client.markdown.unparse(self, self._entities) + return Markdown.unparse(self, self.entities) @property def html(self): - return self._client.html.unparse(self, self._entities) + return HTML.unparse(self, self.entities) def __getitem__(self, item): return utils.remove_surrogates(utils.add_surrogates(self)[item]) @@ -490,7 +484,7 @@ class Message(Object, Update): if isinstance(message, types.Message): entities = [MessageEntity._parse(client, entity, users) for entity in message.entities] - entities = list(filter(lambda x: x is not None, entities)) + entities = pyrogram.List(filter(lambda x: x is not None, entities)) forward_from = None forward_sender_name = None @@ -607,8 +601,8 @@ class Message(Object, Update): date=message.date, chat=Chat._parse(client, message, users, chats), from_user=User._parse(client, users.get(message.from_id, None)), - text=Str(message.message).init(client, entities) or None if media is None else None, - caption=Str(message.message).init(client, entities) or None if media is not None else None, + text=Str(message.message).init(entities) or None if media is None else None, + caption=Str(message.message).init(entities) or None if media is not None else None, entities=entities or None if media is None else None, caption_entities=entities or None if media is not None else None, author_signature=message.post_author,