Skip to content

Commit

Permalink
feat(telegram): support code block and enhance code support (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
amam11ya authored Aug 15, 2024
1 parent 8ef03a7 commit 6995364
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adapters/telegram/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ export class TelegramMessageEncoder<C extends Context = Context> extends Message
await this.render(children)
this.payload.caption += '</tg-spoiler>'
} else if (type === 'code') {
this.payload.caption += `<code>${attrs.content ? h.escape(attrs.content) : children.toString()}</code>`
} else if (type === 'code-block') {
const { lang } = attrs
this.payload.caption += `<code${lang ? ` class="language-${lang}"` : ''}>${h.escape(attrs.content)}</code>`
this.payload.caption += `<pre><code${lang ? ` class="language-${lang}"` : ''}>${children.toString()}</code></pre>`
} else if (type === 'at') {
if (attrs.id) {
this.payload.caption += `<a href="tg://user?id=${attrs.id}">@${attrs.name || attrs.id}</a>`
Expand Down

0 comments on commit 6995364

Please sign in to comment.