mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Add support for custom emoji in HTML
This commit is contained in:
parent
2242adb598
commit
f5bcce7c3f
2 changed files with 10 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue