mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -68,11 +68,11 @@ export async function closeBotClient(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forward a message from a channel to a user's DM.
|
* Copy a message from a channel to a user's DM.
|
||||||
* Uses forwardMessages with send_copy to make it appear as sent by the bot.
|
* 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
|
* The fromChatId is the Telegram chat ID from the DB (e.g. -1003767441152).
|
||||||
* format (negative for supergroups/channels, e.g. -1001234567890).
|
* The messageId is the TDLib message ID stored in the DB.
|
||||||
*/
|
*/
|
||||||
export async function copyMessageToUser(
|
export async function copyMessageToUser(
|
||||||
fromChatId: bigint,
|
fromChatId: bigint,
|
||||||
@@ -82,18 +82,25 @@ export async function copyMessageToUser(
|
|||||||
if (!client) throw new Error("Bot client not initialized");
|
if (!client) throw new Error("Bot client not initialized");
|
||||||
const c = client;
|
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({
|
c.invoke({
|
||||||
_: "forwardMessages",
|
_: "forwardMessages",
|
||||||
chat_id: Number(toUserId),
|
chat_id: Number(toUserId),
|
||||||
from_chat_id: Number(fromChatId),
|
from_chat_id: Number(fromChatId),
|
||||||
message_ids: [Number(messageId)],
|
message_ids: [Number(messageId)],
|
||||||
send_copy: true,
|
send_copy: false,
|
||||||
remove_caption: false,
|
remove_caption: false,
|
||||||
}),
|
}),
|
||||||
"copyMessageToUser"
|
"copyMessageToUser"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
log.info({ result: JSON.stringify(result) }, "forwardMessages result");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user