mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-04 10:14:47 +08:00
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:
committed by
exe.dev user
parent
4a8887636c
commit
221c4948cd
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user