The command exited with code 0. Output: 3122:bot.action(/^BUY_PLAN_(\w+)_(\d+)$/, async (ctx) => { 3123- ctx.answerCbQuery().catch(() => { }); 3124- const planType = ctx.match[1]; 3125- const amount = parseInt(ctx.match[2]); 3126- const userId = ctx.from.id; 3127- 3128- let plans = []; 3129- try { 3130- const fs = require('fs'); 3131- plans = JSON.parse(fs.readFileSync(__dirname + '/plans.json', 'utf8')); 3132- } catch(e) { 3133- plans = []; 3134- } 3135- 3136- let planLabel = planType.charAt(0).toUpperCase() + planType.slice(1); 3137- const matchedPlan = plans.find(p => p.type === planType); 3138- if (matchedPlan) planLabel = matchedPlan.label.replace(' šŸ’Ž', ''); 3139- 3140- console.log(`[PAYMENT] User ${userId} selected ${planLabel} Plan (₹${amount})`); 3141- 3142- if (amount > 20000) { 3143- return ctx.reply(`šŸ’Ž ${planLabel} Plan\n\nFor amounts above ₹20,000, please directly DM our admin @EverythingBypass to arrange the payment and activation.\n\nšŸ‘‰ Click here to contact @EverythingBypass`, { 3144- parse_mode: 'HTML', 3145- disable_web_page_preview: true 3146- }); 3147- } 3148- 3149- try { 3150- if (process.env.DATABASE_URL) { 3151- const userRes = await pool.query('SELECT credits FROM users WHERE telegram_id = $1', [userId]); 3152- if (userRes.rows.length > 0) { 3153- const currentCredits = Number(userRes.rows[0].credits || 0); 3154- if (currentCredits >= amount) { 3155- const planDurations = { 3156- 'daily': 24 * 60 * 60 * 1000, 3157- 'weekly': 7 * 24 * 60 * 60 * 1000, 3158- 'monthly': 30 * 24 * 60 * 60 * 1000, 3159- '2months': 60 * 24 * 60 * 60 * 1000, 3160- 'yearly': 365 * 24 * 60 * 60 * 1000, 3161- 'lifetime': 10 * 365 * 24 * 60 * 60 * 1000 3162- }; 3163- const duration = planDurations[planType] || (30 * 24 * 60 * 60 * 1000); 3164- const planExpiresAt = new Date(Date.now() + duration); 3165- const planExpiryStr = planExpiresAt.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' }); 3166- 3167- await pool.query( 3168- `UPDATE users SET credits = credits - $1, plan_type = 'unlimited', plan_expires_at = $2, plan_started_at = NOW(), updated_at = NOW() WHERE telegram_id = $3`, 3169- [amount, planExpiresAt, userId] 3170- ); 3171- 3172- return ctx.reply(`āœ… Payment Successful! (Paid from Wallet)\n\n` + 3173- `šŸ’Ž You have successfully purchased the ${planLabel} Plan for ₹${amount}.\n` + 3174- `ā³ Plan Expires: ${planExpiryStr}\n\n` + 3175- `Enjoy your unlimited searches!`, { parse_mode: 'HTML' }); 3176- } 3177- } 3178- } 3179- } catch (e) { 3180- console.error("Wallet deduction error:", e); 3181- } 3182- 3183- const loadMsg = await ctx.reply(`ā³ Generating secure payment QR for ${planLabel} Plan (₹${amount})... Please wait.`, { parse_mode: 'HTML' }); 3184- 3185- try { 3186- await generatePaymentRequest(ctx, userId, amount, planType, loadMsg); 3187- } catch (err) { 3188- console.error("Plan purchase generation error:", err.message); 3189- ctx.reply(`āŒ Failed to generate payment: ${err.message}`, { parse_mode: 'HTML' }); 3190- } 3191-}); 3192- 3193-// Manual Captcha Fetch 3194-async function fetchManualCaptcha(ctx, session) { 3195- try { 3196- const captchaResponse = await callApi('/captcha', { method: 'GET' }); 3197- 3198- if (!captchaResponse.ok) { 3199- ctx.reply(`āŒ *Could not load verification image. Please try again.*`, { parse_mode: 'Markdown' }); 3200- return; 3201- } 3202- 3203- const data = await captchaResponse.json(); 3204- session.transactionId = data.captchaTxnId; 3205- const imageBuffer = Buffer.from(data.captchaBase64, 'base64'); 3206- 3207- await ctx.replyWithPhoto({ source: imageBuffer }, { 3208- caption: 'āš ļø *Auto-verification paused.*\n\n*Please type the exact characters shown in the image below:*', 3209- parse_mode: 'Markdown' 3210- }); 3211- session.step = session.pdfPhase ? 'WAITING_FOR_MANUAL_CAPTCHA_PDF' : 'WAITING_FOR_MANUAL_CAPTCHA'; 3212- } catch (error) { 3213- console.error(error); 3214- ctx.reply('āŒ *A temporary error occurred while fetching verification image.*', { parse_mode: 'Markdown' }); 3215- } 3216-} 3217- 3218-// Auto-Retry Loop Function 3219-async function autoSolveAndRequestOtp(ctx, session, attempt = 1, statusMessageId = null) { 3220- // 5 invisible tries: allows AI to get a clear captcha without bothering the user 3221- if (attempt > 5) { 3222- if (statusMessageId) ctx.telegram.deleteMessage(ctx.chat.id, statusMessageId).catch(() => { });