mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Parse message entities (As HTML and markdown) and update markdown utils (add html mode)
This commit is contained in:
parent
bc917ec9f5
commit
42245fc58a
3 changed files with 84 additions and 3 deletions
|
|
@ -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':
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue