diff --git a/src/bot/message-sender.js b/src/bot/message-sender.js index 07990899..3f0039fb 100644 --- a/src/bot/message-sender.js +++ b/src/bot/message-sender.js @@ -58,23 +58,12 @@ export async function sendStreamingMessage(ctx, text, options = {}) { // Send initial placeholder message using ctx.api.sendMessage directly const sentMsg = await ctx.api.sendMessage(ctx.chat.id, '⌨️ ⌨️', { parse_mode: 'Markdown' }); - logger.info('📡 Reply response type:', typeof sentMsg); - logger.info('📡 Reply response keys:', sentMsg ? Object.keys(sentMsg) : 'null'); + logger.info('📡 Full response:', JSON.stringify(sentMsg, null, 2).substring(0, 500)); - // Handle Telegram API response format (can be array-like) - let messageId, chatId; - if (sentMsg?.message_id !== undefined) { - messageId = sentMsg.message_id; - chatId = sentMsg.chat?.id; - } else if (Array.isArray(sentMsg) || Object.keys(sentMsg).every(k => /^\d+$/.test(k))) { - // Array-like response from Telegram API - messageId = sentMsg[0]?.message_id || sentMsg['message_id']; - chatId = sentMsg[0]?.chat?.id || sentMsg['chat']?.id; - } else { - // Try direct property access - messageId = sentMsg?.['message_id'] || sentMsg?.[0]?.['message_id']; - chatId = sentMsg?.['chat']?.['id'] || sentMsg?.[0]?.['chat']?.['id']; - } + // The Telegram API returns a response with numeric keys mapping to property names + // We need to access sentMsg['message_id'] directly + const messageId = sentMsg?.['message_id']; + const chatId = sentMsg?.['chat']?.['id']; logger.info('📡 Extracted Message ID:', messageId); logger.info('📡 Extracted Chat ID:', chatId);