mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Add support for CUSTOM_EMOJI message entity type
This commit is contained in:
parent
c26c1004ad
commit
cd69fb6d76
@ -77,5 +77,8 @@ class MessageEntityType(AutoName):
|
||||
BANK_CARD = raw.types.MessageEntityBankCard
|
||||
"Bank card text"
|
||||
|
||||
CUSTOM_EMOJI = raw.types.MessageEntityCustomEmoji
|
||||
"Custom emoji"
|
||||
|
||||
UNKNOWN = raw.types.MessageEntityUnknown
|
||||
"Unknown message entity type"
|
||||
|
@ -40,13 +40,17 @@ class MessageEntity(Object):
|
||||
Length of the entity in UTF-16 code units.
|
||||
|
||||
url (``str``, *optional*):
|
||||
For "text_link" only, url that will be opened after user taps on the text.
|
||||
For :obj:`~pyrogram.enums.MessageEntityType.TEXT_LINK` only, url that will be opened after user taps on the text.
|
||||
|
||||
user (:obj:`~pyrogram.types.User`, *optional*):
|
||||
For "text_mention" only, the mentioned user.
|
||||
For :obj:`~pyrogram.enums.MessageEntityType.TEXT_MENTION` only, the mentioned user.
|
||||
|
||||
language (``str``. *optional*):
|
||||
language (``str``, *optional*):
|
||||
For "pre" only, the programming language of the entity text.
|
||||
|
||||
custom_emoji_id (``int``, *optional*):
|
||||
For :obj:`~pyrogram.enums.MessageEntityType.CUSTOM_EMOJI` only, unique identifier of the custom emoji.
|
||||
Use :meth:`~pyrogram.Client.get_custom_emoji_stickers` to get full information about the sticker.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@ -58,7 +62,8 @@ class MessageEntity(Object):
|
||||
length: int,
|
||||
url: str = None,
|
||||
user: "types.User" = None,
|
||||
language: str = None
|
||||
language: str = None,
|
||||
custom_emoji_id: int = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
@ -68,6 +73,7 @@ class MessageEntity(Object):
|
||||
self.url = url
|
||||
self.user = user
|
||||
self.language = language
|
||||
self.custom_emoji_id = custom_emoji_id
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, entity: "raw.base.MessageEntity", users: dict) -> Optional["MessageEntity"]:
|
||||
@ -87,6 +93,7 @@ class MessageEntity(Object):
|
||||
url=getattr(entity, "url", None),
|
||||
user=types.User._parse(client, users.get(user_id, None)),
|
||||
language=getattr(entity, "language", None),
|
||||
custom_emoji_id=getattr(entity, "document_id", None),
|
||||
client=client
|
||||
)
|
||||
|
||||
@ -105,6 +112,9 @@ class MessageEntity(Object):
|
||||
if self.language is None:
|
||||
args.pop("language")
|
||||
|
||||
if self.custom_emoji_id is None:
|
||||
args.pop("custom_emoji_id")
|
||||
|
||||
entity = self.type.value
|
||||
|
||||
if entity is raw.types.MessageEntityMentionName:
|
||||
|
Loading…
Reference in New Issue
Block a user