Skip to content

Commit 2261daf

Browse files
Add message.content property
Co-authored-by: KurimuzonAkuma <[email protected]>
1 parent 366d337 commit 2261daf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pyrogram/types/messages_and_media/message.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ class Message(Object, Update):
419419
link (``str``, *property*):
420420
Generate a link to this message, only for supergroups and channels. Can be None if the message cannot have a link.
421421
422+
content (``str``, *property*):
423+
The text or caption content of the message.
424+
If the message contains entities (bold, italic, ...) you can access *content.markdown* or
425+
*content.html* to get the marked up content. In case there is no caption entity, the fields
426+
will contain the same text as *content*.
427+
422428
"""
423429

424430
# TODO: Add game missing field.
@@ -1462,6 +1468,10 @@ def link(self) -> str:
14621468
return f"https://t.me/{self.chat.username}{f'/{self.message_thread_id}' if self.message_thread_id else ''}/{self.id}"
14631469
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}{f'/{self.message_thread_id}' if self.message_thread_id else ''}/{self.id}"
14641470

1471+
@property
1472+
def content(self) -> str:
1473+
return self.text or self.caption or Str("").init([])
1474+
14651475
async def get_media_group(self) -> list["types.Message"]:
14661476
"""Bound method *get_media_group* of :obj:`~pyrogram.types.Message`.
14671477

0 commit comments

Comments
 (0)