From 8f4b1126da1a85ceffbe2007e9d6dc1b4e83944f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=A2=E5=AD=90?= Date: Mon, 20 Apr 2026 01:31:42 +0000 Subject: [PATCH] fix: delete /personality message after sending to reduce chat clutter --- src/commands/personality.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/personality.ts b/src/commands/personality.ts index ad5f02b..bd7999e 100644 --- a/src/commands/personality.ts +++ b/src/commands/personality.ts @@ -189,9 +189,17 @@ async function switchTelegram(name: string) { body: JSON.stringify({ chat_id: chatId, text: `/personality ${displayName}` }), }); - const result = await resp.json() as { ok: boolean; description?: string }; + const result = await resp.json() as { ok: boolean; description?: string; result?: { message_id: number } }; if (result.ok) { console.log(`Sent /personality ${displayName} to chat ${chatId}`); + // Delete the message so it doesn't clutter the chat + if (result.result?.message_id) { + await fetch(`https://api.telegram.org/bot${token}/deleteMessage`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ chat_id: chatId, message_id: result.result.message_id }), + }).catch(() => {}); + } } else { console.error(`Telegram API error: ${result.description}`); process.exit(1);