Created At: 2026-11-18T04:42:39Z Completed At: 2026-11-18T04:42:39Z Command exited with code 0. Command output: method: 'POST', body: JSON.stringify(otpReqBody), signal: AbortSignal.timeout(12000) }); otpData = await otpResponse.json(); console.timeEnd(tLabel('Backend Request')); } console.log(`[Attempt ${attempt}] Backend Response Status:`, otpResponse.status, otpData); if (otpResponse.ok && otpData.status === "success") { if (statusMessageId) ctx.telegram.deleteMessage(ctx.chat.id, statusMessageId).catch(() => { }); if (session.startLoaderId) { ctx.telegram.deleteMessage(ctx.chat.id, session.startLoaderId).catch(() => { }); session.startLoaderId = null; } session.otpTxnId = otpData.otpTxnId || otpData.txnId; ctx.reply(`šŸ“© OTP Sent Successfully!\n\nPlease enter the 6-digit OTP sent to your registered mobile number:\n\nšŸ’” Send /cancel to cancel this process.`, { parse_mode: 'HTML' }); session.step = (session.pdfPhase || session.serviceType === 'EID_TO_PDF') ? 'WAITING_FOR_PDF_OTP' : 'WAITING_FOR_OTP'; console.timeEnd(tLabel('Total Loop')); } else { let errMsg = otpData ? (otpData.message || (otpData.data && otpData.data.data && otpData.data.data.message) || (otpData.data && otpData.data.message)) : null; if (errMsg && typeof errMsg === 'string' && !errMsg.toLowerCase().includes('captcha')) { console.log(`[Attempt ${attempt}] Validation error:`, errMsg); if (statusMessageId) ctx.telegram.deleteMessage(ctx.chat.id, statusMessageId).catch(() => { }); ctx.reply(`āš ļø Error: ${sanitizeError(errMsg)}\n\nPlease check your details and try again.`, { parse_mode: 'HTML' }); delete sessions[ctx.chat.id]; return; } console.log(`[Attempt ${attempt}] Backend returned non-success status or HTTP error. Retrying...`); if (attempt >= 3 && errMsg && !errMsg.toLowerCase().includes('captcha')) { if (statusMessageId) ctx.telegram.deleteMessage(ctx.chat.id, statusMessageId).catch(() => { }); ctx.reply(`āš ļø Error: ${sanitizeError(errMsg)}\n\nPlease try again later.`, { parse_mode: 'HTML' }); delete sessions[ctx.chat.id]; return; } await new Promise(r => setTimeout(r, 500)); try { console.timeEnd(tLabel('Total Loop')); } catch (err) {} await autoSolveAndRequestOtp(ctx, session, attempt + 1, statusMessageId); } } catch (error) { console.error("Network Error (Retry):", error.code || error.message); try { console.timeEnd(tLabel('Total Loop')); } catch (e) { console.error("Error:", e); } await new Promise(r => setTimeout(r, 500)); await autoSolveAndRequestOtp(ctx, session, attempt + 1, statusMessageId); } } // Action Handlers for Buttons bot.action('CAPTCHA_AUTO', async (ctx) => { const userId = ctx.chat.id; const session = sessions[userId]; if (!session) return; if (await handlePayText(ctx, userId, session)) return; ctx.answerCbQuery().catch(() => { }); ctx.editMessageText('ā³ Loading... Please wait.', { parse_mode: 'HTML' }); session.step = session.pdfPhase ? 'SOLVING_CAPTCHA_PDF' : 'SOLVING_CAPTCHA'; await autoSolveAndRequestOtp(ctx, session, 1); }); bot.action('CAPTCHA_MANUAL', async (ctx) => { const userId = ctx.chat.id; const session = sessions[userId]; if (!session) return; if (await handlePayText(ctx, userId, session)) return; ctx.answerCbQuery().catch(() => { }); ctx.editMessageText('āœļø Switching to manual verification...', { parse_mode: 'HTML' }); await fetchManualCaptcha(ctx, session); }); bot.action('CHOOSE_WITH_DOB', async (ctx) => { const userId = ctx.chat.id; const session = sessions[userId]; if (!session) return; if (await handlePayText(ctx, userId, session)) return; ctx.answerCbQuery().catch(() => { }); ctx.editMessageText('šŸ“… Please enter your Date of Birth (in DD/MM/YYYY format):', { parse_mode: 'HTML' }); session.step = 'WAITING_FOR_DOB_VAL'; }); bot.action('CHOOSE_WITHOUT_DOB', async (ctx) => { const userId = ctx.chat.id; const session = sessions[userId]; if (!session) return; if (await handlePayText(ctx, userId, session)) return; ctx.answerCbQuery().catch(() => { }); ctx.deleteMessage().catch(() => { }); session.dob = null; session.step = 'SOLVING_CAPTCHA'; const ldr = await ctx.reply('ā³ Loading... Please wait.', { parse_mode: 'HTML' }); await autoSolveAndRequestOtp(ctx, session, 1, ldr.message_id); }); bot.action('CACHE_CONFIRM_NO', async (ctx) => { const userId = ctx.chat.id; const session = sessions[userId]; ctx.answerCbQuery().catch(() => { }); if (!session) { return ctx.reply("āŒ Session Expired: Please send /start to begin a new request.", { parse_mode: 'HTML' }); } // Discard cached record and proceed with normal Name verification