diff --git a/src/bot/message-sender.js b/src/bot/message-sender.js index 2f609785..23313203 100644 --- a/src/bot/message-sender.js +++ b/src/bot/message-sender.js @@ -58,14 +58,18 @@ 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' }); - // Log response structure + // Log response structure - try to understand the format logger.info('📡 Response typeof:', typeof sentMsg); - logger.info('📡 Response keys:', Object.keys(sentMsg || {}).join(', ')); - logger.info('📡 sentMsg keys:', sentMsg ? Object.keys(sentMsg).join(', ') : 'null'); + logger.info('📡 sentMsg:', JSON.stringify(sentMsg).substring(0, 300)); + + // The response might be wrapped in a 'result' property + const response = sentMsg?.result || sentMsg; + logger.info('📡 Response type:', typeof response); + logger.info('📡 Response keys:', Object.keys(response || {}).join(', ')); // Try different access patterns - const messageId = sentMsg?.['message_id'] || sentMsg?.message_id || sentMsg?.[0]?.['message_id']; - const chatId = sentMsg?.['chat']?.['id'] || sentMsg?.chat?.id || sentMsg?.[0]?.['chat']?.['id']; + const messageId = response?.['message_id'] || response?.message_id; + const chatId = response?.['chat']?.['id'] || response?.chat?.id; logger.info('📡 Extracted Message ID:', messageId); logger.info('📡 Extracted Chat ID:', chatId);