diff --git a/src/channels/telegram.ts b/src/channels/telegram.ts index dfd42323f..de1f70575 100644 --- a/src/channels/telegram.ts +++ b/src/channels/telegram.ts @@ -216,6 +216,21 @@ registerChannelAdapter('telegram', { const wrapped: ChannelAdapter = { ...bridge, + resolveChannelName: async (platformId: string) => { + const chatId = platformId.split(':').slice(1).join(':'); + if (!chatId) return null; + try { + const res = await fetch(`https://api.telegram.org/bot${token}/getChat`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ chat_id: chatId }), + }); + const data = (await res.json()) as { ok?: boolean; result?: { title?: string } }; + return data.ok ? (data.result?.title ?? null) : null; + } catch { + return null; + } + }, async setup(hostConfig: ChannelSetup) { const intercepted: ChannelSetup = { ...hostConfig,