/clear из лички: выбор чата кнопками с подтверждением

- /clear в личке с ботом показывает чаты с контекстом диалога (название и число реплик), дальше подтверждение
- /clear <ID чата> в личке — сразу подтверждение для этого чата; в группе /clear работает как раньше
- Общий хелпер chatTitle для /archive и /clear

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yunogasai
2026-09-25 15:17:18 +02:00
parent f5d1ea6be2
commit 08108f5e1f
7 changed files with 99 additions and 17 deletions

10
src/bot/chat-title.ts Normal file
View File

@@ -0,0 +1,10 @@
import type { Context } from "grammy";
/** Как называть чат в списках: название группы или имя в личке; если Telegram не ответил — ID. */
export const chatTitle = async (ctx: Context, chatId: number): Promise<string> => {
const chat = await ctx.api.getChat(chatId).catch(() => undefined);
if (!chat) return String(chatId);
return "title" in chat && chat.title ? chat.title : `личка ${chat.first_name ?? chatId}`;
};