import type { Context } from "grammy"; /** Как называть чат в списках: название группы или имя в личке; если Telegram не ответил — ID. */ export const chatTitle = async (ctx: Context, chatId: number): Promise => { 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}`; };