pyrofork: Add support for custom emoji in markdown unparser
Some checks failed
Build-docs / build (push) Has been cancelled
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2025-03-03 04:41:19 +07:00
parent e58354c98a
commit 2de6d80905
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -234,11 +234,18 @@ class Markdown:
# No closing delimiter for blockquotes # No closing delimiter for blockquotes
else: else:
url = None url = None
is_emoji = False
if entity.type == MessageEntityType.TEXT_LINK: if entity.type == MessageEntityType.TEXT_LINK:
url = entity.url url = entity.url
elif entity.type == MessageEntityType.TEXT_MENTION: elif entity.type == MessageEntityType.TEXT_MENTION:
url = f'tg://user?id={entity.user.id}' url = f'tg://user?id={entity.user.id}'
elif entity.type == MessageEntityType.CUSTOM_EMOJI:
url = f"tg://emoji?id={entity.custom_emoji_id}"
is_emoji = True
if url: if url:
if is_emoji:
insert_at.append((s, i, '!['))
else:
insert_at.append((s, i, '[')) insert_at.append((s, i, '['))
insert_at.append((e, -i, f']({url})')) insert_at.append((e, -i, f']({url})'))