From f5bcce7c3f96e9ebfb87791f69ee96f649ab481c Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Tue, 16 Aug 2022 08:59:06 +0200
Subject: [PATCH] Add support for custom emoji in HTML
---
docs/source/topics/text-formatting.rst | 2 ++
pyrogram/parser/html.py | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/docs/source/topics/text-formatting.rst b/docs/source/topics/text-formatting.rst
index 4e11fb74..00aa0cf8 100644
--- a/docs/source/topics/text-formatting.rst
+++ b/docs/source/topics/text-formatting.rst
@@ -122,6 +122,8 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.HTML` to the *parse_mode*
inline fixed-width code
+
pre-formatted fixed-width diff --git a/pyrogram/parser/html.py b/pyrogram/parser/html.py index d9a8d368..29c8c4a6 100644 --- a/pyrogram/parser/html.py +++ b/pyrogram/parser/html.py @@ -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'' end_tag = "" + elif entity_type == MessageEntityType.CUSTOM_EMOJI: + custom_emoji_id = entity.custom_emoji_id + start_tag = f'' + end_tag = " " else: continue