Parse message entities (As HTML and markdown) and update markdown utils (add html mode)

This commit is contained in:
Alex Root Junior 2017-07-23 02:40:25 +03:00
parent bc917ec9f5
commit 42245fc58a
3 changed files with 84 additions and 3 deletions

View file

@ -8,7 +8,7 @@ from .document import Document
from .game import Game
from .invoice import Invoice
from .location import Location
from .message_entity import MessageEntity
from .message_entity import MessageEntity, MessageEntityType
from .photo_size import PhotoSize
from .sticker import Sticker
from .successful_payment import SuccessfulPayment
@ -179,6 +179,26 @@ class Message(Deserializable):
if command:
return command[1].strip()
@property
def md_text(self):
text = self.text
if self.text and self.entities:
for entity in reversed(self.entities):
text = entity.apply_md(text)
return text
@property
def html_text(self):
text = self.text
if self.text and self.entities:
for entity in reversed(self.entities):
text = entity.apply_html(text)
return text
async def reply(self, text, parse_mode=None, disable_web_page_preview=None,
disable_notification=None, reply_markup=None) -> 'Message':
"""