fix: enable link previews in forwarded messages based on content URLs
This commit is contained in:
parent
4603abe3c6
commit
2643756443
1 changed files with 5 additions and 1 deletions
|
|
@ -18,11 +18,15 @@ export async function forwardMessage(opts: ForwardMessageOptions): Promise<void>
|
||||||
const roleText = role ? ` (${escapeHtml(role)})` : ''
|
const roleText = role ? ` (${escapeHtml(role)})` : ''
|
||||||
const text = `<b>${escapeHtml(author)}</b>${roleText} in <code>#${escapeHtml(channel)}</code>\n${escapeHtml(content)}\n\n<a href="${messageLink}">Jump to message</a>`
|
const text = `<b>${escapeHtml(author)}</b>${roleText} in <code>#${escapeHtml(channel)}</code>\n${escapeHtml(content)}\n\n<a href="${messageLink}">Jump to message</a>`
|
||||||
|
|
||||||
|
// Enable link preview only if content has URLs (not just the discord jump link)
|
||||||
|
const hasLinks = /https?:\/\/\S+/i.test(content)
|
||||||
|
|
||||||
await telegram.api.sendMessage({
|
await telegram.api.sendMessage({
|
||||||
chat_id: config.telegram.chatId,
|
chat_id: config.telegram.chatId,
|
||||||
text,
|
text,
|
||||||
message_thread_id: topicId,
|
message_thread_id: topicId,
|
||||||
parse_mode: 'HTML'
|
parse_mode: 'HTML',
|
||||||
|
link_preview_options: { is_disabled: !hasLinks },
|
||||||
})
|
})
|
||||||
|
|
||||||
if (attachments.length === 0)
|
if (attachments.length === 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue