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
+17
View File
@@ -49,6 +49,11 @@ export interface TelegramBotCommand {
description: string
}
export interface TelegramInputRichMessage {
markdown: string
skip_entity_detection?: boolean
}
export interface TelegramClientOptions {
fetch?: typeof fetch
baseUrl?: string
@@ -64,6 +69,7 @@ export interface TelegramClientLike {
parseMode?: string,
replyMarkup?: InlineKeyboardMarkup,
): Promise<TelegramMessage>
sendRichMessage(chatId: number, markdown: string): Promise<TelegramMessage>
sendChatAction(chatId: number, action: string): Promise<boolean>
answerCallbackQuery(callbackQueryId: string, text?: string): Promise<boolean>
setMyCommands(commands: TelegramBotCommand[]): Promise<boolean>
@@ -167,6 +173,17 @@ export class TelegramClient implements TelegramClientLike {
return this.call<TelegramMessage>('sendMessage', body)
}
async sendRichMessage(chatId: number, markdown: string): Promise<TelegramMessage> {
const body: Record<string, unknown> = {
chat_id: chatId,
rich_message: {
markdown,
skip_entity_detection: true,
},
}
return this.call<TelegramMessage>('sendRichMessage', body)
}
async sendChatAction(chatId: number, action: string): Promise<boolean> {
return this.call<boolean>('sendChatAction', { chat_id: chatId, action })
}