feat(telegram): implement resolveChannelName via getChat API

Enables the channel-approval flow to show the Telegram group name
in the approval card instead of a generic "a telegram channel".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gabi-simons
2026-04-30 12:56:12 +00:00
committed by exe.dev user
parent 4a8887636c
commit 221c4948cd
+15
View File
@@ -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,