2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-23 10:28:00 +00:00

Add support for custom emoji in HTML

This commit is contained in:
Dan 2022-08-16 08:59:06 +02:00
parent 2242adb598
commit f5bcce7c3f
2 changed files with 10 additions and 0 deletions

View File

@ -122,6 +122,8 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.HTML` to the *parse_mode*
<code>inline fixed-width code</code>
<emoji id="12345678901234567890">🔥</emoji>
<pre>
pre-formatted
fixed-width

View File

@ -75,6 +75,10 @@ class Parser(HTMLParser):
else:
entity = raw.types.MessageEntityTextUrl
extra["url"] = url
elif tag == "emoji":
entity = raw.types.MessageEntityCustomEmoji
custom_emoji_id = int(attrs.get("id"))
extra["document_id"] = custom_emoji_id
else:
return
@ -185,6 +189,10 @@ class HTML:
user = entity.user
start_tag = f'<a href="tg://user?id={user.id}">'
end_tag = "</a>"
elif entity_type == MessageEntityType.CUSTOM_EMOJI:
custom_emoji_id = entity.custom_emoji_id
start_tag = f'<emoji id="{custom_emoji_id}">'
end_tag = "</emoji>"
else:
continue