Added decorations for custom emoji (suppressed on server side)

This commit is contained in:
Alex Root Junior 2022-08-13 23:38:38 +03:00
parent 11d2e6f31a
commit e7b58e4938
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC

View file

@ -182,7 +182,7 @@ class HtmlDecoration(TextDecoration):
return html.escape(value, quote=False)
def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
return value
return f'<tg-emoji emoji-id="{custom_emoji_id}">{value}</tg-emoji>'
class MarkdownDecoration(TextDecoration):
@ -219,7 +219,7 @@ class MarkdownDecoration(TextDecoration):
return re.sub(pattern=self.MARKDOWN_QUOTE_PATTERN, repl=r"\\\1", string=value)
def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
return value
return self.link(value=value, link=f"tg://emoji?id={custom_emoji_id}")
html_decoration = HtmlDecoration()