feat: use Telegram native Rich Message for assistant replies

Co-authored-by: MuziIsabel <MuziIsabel@users.noreply.github.com>
This commit is contained in:
MuziIsabel
2026-08-18 18:27:32 +08:00
committed by GitHub
co-authored by MuziIsabel
parent 819010de1c
commit 93f3bec975
15 changed files with 675 additions and 0 deletions
+21
View File
@@ -51,3 +51,24 @@ test('sendMessage can include reply_markup', async () => {
inline_keyboard: [[{ text: 'A', callback_data: 'bind:1' }]],
})
})
test('sendRichMessage posts native rich markdown body', async () => {
const calls: Array<{ url: string; body: Record<string, unknown> }> = []
const fetchImpl: typeof fetch = async (input, init) => {
calls.push({ url: String(input), body: JSON.parse(String(init?.body)) })
return new Response(JSON.stringify({
ok: true,
result: { message_id: 2, date: 0, chat: { id: 1, type: 'private' }, text: '# hi' },
}), { status: 200 })
}
const client = new TelegramClient('TOK', { fetch: fetchImpl })
await client.sendRichMessage(1, '# hi\n\n- a\n- b')
assert.match(calls[0]!.url, /\/botTOK\/sendRichMessage$/)
assert.deepEqual(calls[0]!.body, {
chat_id: 1,
rich_message: {
markdown: '# hi\n\n- a\n- b',
skip_entity_detection: true,
},
})
})