From 84bb167ce6a96d89506499550a381145ea2a3854 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 22 Mar 2026 11:33:46 +0100 Subject: [PATCH] fix: load bot chat list after TDLib auth to enable message forwarding Without getChats after login, TDLib doesn't know about the destination channel and forwardMessages fails with "Chat not found". Co-Authored-By: Claude Opus 4.6 (1M context) --- bot/src/tdlib/client.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bot/src/tdlib/client.ts b/bot/src/tdlib/client.ts index 1b3fb64..e4485c8 100644 --- a/bot/src/tdlib/client.ts +++ b/bot/src/tdlib/client.ts @@ -38,6 +38,20 @@ export async function createBotClient(): Promise { })); log.info("Bot client authenticated successfully"); + + // Load chat list so TDLib knows about channels the bot has access to. + // Without this, forwardMessages/copyMessage will fail with "Chat not found". + try { + await client.invoke({ + _: "getChats", + chat_list: { _: "chatListMain" }, + limit: 200, + }); + log.info("Chat list loaded"); + } catch (err) { + log.warn({ err }, "Failed to load chat list — forwarding may fail"); + } + return client; }