Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new emoji conversion bits to the HTML/MDv2 parsers #96

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add new emoji conversion bits to the HTML/MDv2 parsers
PaulSonOfLars committed Jun 14, 2023
commit c84dedf9099777f2a5e44fe62d77e44f47ab88ef
6 changes: 6 additions & 0 deletions formatting.go
Original file line number Diff line number Diff line change
@@ -193,6 +193,8 @@ func writeFinalHTML(data []uint16, ent MessageEntity, start int64, cntnt string)
}
// <pre><code class="lang">text</code></pre>
return prevText + `<pre><code class="` + ent.Language + `">` + cntnt + "</code></pre>"
case "custom_emoji":
return prevText + `<tg-emoji emoji-id="` + ent.CustomEmojiId + `">` + cntnt + "</tg-emoji>"
case "text_mention":
return prevText + `<a href="tg://user?id=` + strconv.FormatInt(ent.User.Id, 10) + `">` + cntnt + "</a>"
case "text_link":
@@ -216,6 +218,10 @@ func writeFinalMarkdownV2(data []uint16, ent MessageEntity, start int64, cntnt s
switch ent.Type {
case "bold", "italic", "code", "underline", "strikethrough", "pre", "spoiler":
return prevText + pre + mdV2Map[ent.Type] + cleanCntnt + mdV2Map[ent.Type] + post
case "custom_emoji":
// Yes, custom emoji have a weird little ! at the front
// https://core.telegram.org/bots/api#markdownv2-style
return prevText + pre + "![" + cleanCntnt + "](tg://emoji?id=" + ent.CustomEmojiId + ")" + post
case "text_mention":
return prevText + pre + "[" + cleanCntnt + "](tg://user?id=" + strconv.FormatInt(ent.User.Id, 10) + ")" + post
case "text_link":