From 729f2962323ea0be56c65eb5d57fd88794fe8e29 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 22 Mar 2026 12:38:24 +0100 Subject: [PATCH] fix: use forward (not send_copy) for bot message delivery and add logging send_copy requires re-uploading which may silently fail for bots. Regular forward is more reliable. Added logging to debug delivery. Co-Authored-By: Claude Opus 4.6 (1M context) --- bot/src/tdlib/client.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bot/src/tdlib/client.ts b/bot/src/tdlib/client.ts index e4485c8..a0c0442 100644 --- a/bot/src/tdlib/client.ts +++ b/bot/src/tdlib/client.ts @@ -68,11 +68,11 @@ export async function closeBotClient(): Promise { } /** - * Forward a message from a channel to a user's DM. - * Uses forwardMessages with send_copy to make it appear as sent by the bot. + * Copy a message from a channel to a user's DM. + * Uses forwardMessages (not send_copy) to forward the file directly. * - * The fromChatId is the TDLib chat ID stored in the DB — already in the correct - * format (negative for supergroups/channels, e.g. -1001234567890). + * The fromChatId is the Telegram chat ID from the DB (e.g. -1003767441152). + * The messageId is the TDLib message ID stored in the DB. */ export async function copyMessageToUser( fromChatId: bigint, @@ -82,18 +82,25 @@ export async function copyMessageToUser( if (!client) throw new Error("Bot client not initialized"); const c = client; - await withFloodWait( + log.info( + { fromChatId: fromChatId.toString(), messageId: messageId.toString(), toUserId: toUserId.toString() }, + "Forwarding message to user" + ); + + const result = await withFloodWait( () => c.invoke({ _: "forwardMessages", chat_id: Number(toUserId), from_chat_id: Number(fromChatId), message_ids: [Number(messageId)], - send_copy: true, + send_copy: false, remove_caption: false, }), "copyMessageToUser" ); + + log.info({ result: JSON.stringify(result) }, "forwardMessages result"); } /**