From ac8258f4513a59c6501baf0eae01e1bbea3fb386 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 17 Dec 2018 12:40:32 +0100 Subject: [PATCH] Move Str into message.py --- .../types/messages_and_media/message.py | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index f50dd30b..41766332 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -26,7 +26,6 @@ from ..messages_and_media.photo import Photo from ..pyrogram_type import PyrogramType from ..user_and_chats.chat import Chat from ..user_and_chats.user import User -from ...ext.utils import Str class Message(PyrogramType): @@ -484,8 +483,8 @@ class Message(PyrogramType): 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) or None if media is None else None, - caption=Str(message.message) or None if media is not None else 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, 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, @@ -900,3 +899,29 @@ class Message(PyrogramType): progress=progress, progress_args=progress_args, ) + + +class Str(str): + def __init__(self, *args): + super().__init__() + + self.client = None + self.entities = None + + def init(self, client, entities): + self.client = client + self.entities = entities + + return self + + @property + def text(self): + return self + + @property + def markdown(self): + return self.client.markdown.unparse(self, self.entities) + + @property + def html(self): + return self.client.html.unparse(self, self.entities)