The following changes were made by the replace_file_content tool to: /root/aadharbot/index.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -4264,6 +4264,7 @@ await ctx.telegram.deleteMessage(ctx.chat.id, loadMsg.message_id).catch(() => { }); let userFriendlyMsg = ''; + let isGatewayBusy = false; const lowerMsg = (err.message || '').toLowerCase(); if (lowerMsg.includes('amount') || lowerMsg.includes('range') || lowerMsg.includes('channel') || lowerMsg.includes('limit') || lowerMsg.includes('allowed')) { userFriendlyMsg = `⚠️ Payment Request Failed / भुगतान अनुरोध विफल\n\n` + @@ -4273,6 +4273,7 @@ `
You are generating QR codes too quickly. Please wait a few seconds and try again.\n\n` + `आप बहुत जल्दी-जल्दी QR उत्पन्न कर रहे हैं। कृपया कुछ सेकंड प्रतीक्षा करें और पुनः प्रयास करें।
`; } else { + isGatewayBusy = true; userFriendlyMsg = `⚠️ Gateway Busy / गेटवे व्यस्त है\n\n` + `
The payment gateway is currently busy. Please try generating the QR again after some time.\n\n` + `पेमेंट गेटवे वर्तमान में व्यस्त है। कृपया कुछ समय बाद पुनः प्रयास करें।
`; @@ -4279,5 +4279,44 @@ await ctx.reply(userFriendlyMsg, { parse_mode: 'HTML' }); + + // Send error log to the Telegram logs topic + try { + const logGroupId = process.env.LOG_GROUP_ID || '-1003938329952'; + const errorThreadId = process.env.LOG_ERROR_THREAD_ID ? Number(process.env.LOG_ERROR_THREAD_ID) : 2567; + const userName = ctx.from?.first_name || 'User'; + const username = ctx.from?.username ? `@${ctx.from.username}` : 'None'; + const nowIST = formatDateIST(new Date()); + const cleanErr = (err.message || 'Unknown error').replace(//g, '>'); + const cleanUrl = requestUrl ? requestUrl.replace(//g, '>') : 'None / Not generated'; + + const logMsg = `⚠️ [PAYMENT ${isGatewayBusy ? 'GATEWAY BUSY' : 'REQUEST FAILED'}]\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `👤 User: ${userName} (${username})\n` + + `🆔 User ID: ${userId}\n` + + `💵 Amount: ₹${amount}\n` + + `📦 Plan: ${planType || 'credits'}\n` + + `🌐 Gateway: ${gatewayHost || 'Cashier API'}\n` + + `🕐 Time: ${nowIST}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `🔗 Checkout URL:\n${cleanUrl.substring(0, 400)}\n\n` + + `❌ Error Details:\n
${cleanErr.substring(0, 1000)}
`; + + await bot.telegram.sendMessage(logGroupId, logMsg, { + parse_mode: 'HTML', + message_thread_id: errorThreadId + }).catch(e => console.error("[LOG GROUP] Error sending payment failure to topic:", e.message)); + + // Mirror to user forum topic thread if active + const userThreadId = await getUserThreadId(userId).catch(() => null); + if (userThreadId && userThreadId > 0 && userThreadId !== errorThreadId) { + await bot.telegram.sendMessage(logGroupId, logMsg, { + parse_mode: 'HTML', + message_thread_id: userThreadId + }).catch(() => {}); + } + } catch (logErr) { + console.error("[LOG GROUP] Failed to send payment error notification:", logErr.message); + } } } [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.