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]
@@ -3381,7 +3381,88 @@
ctx.deleteMessage().catch(() => { });
session.dob = null;
session.step = 'SOLVING_CAPTCHA';
- await autoSolveAndRequestOtp(ctx, session, 1);
+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
+ delete session.cachedMatch;
+
+ try {
+ await ctx.editMessageText('👤 Select Name Verification:', {
+ parse_mode: 'HTML',
+ ...Markup.inlineKeyboard([
+ [{ text: 'Name', callback_data: 'CHOOSE_WITH_NAME', style: 'primary' }],
+ [{ text: 'No Name', callback_data: 'CHOOSE_WITHOUT_NAME', style: 'primary' }]
+ ])
+ });
+ } catch (e) {
+ await ctx.reply('👤 Select Name Verification:', {
+ parse_mode: 'HTML',
+ ...Markup.inlineKeyboard([
+ [{ text: 'Name', callback_data: 'CHOOSE_WITH_NAME', style: 'primary' }],
+ [{ text: 'No Name', callback_data: 'CHOOSE_WITHOUT_NAME', style: 'primary' }]
+ ])
+ });
+ }
+});
+
+bot.action('CACHE_CONFIRM_YES', async (ctx) => {
+ const userId = ctx.chat.id;
+ const session = sessions[userId];
+ ctx.answerCbQuery().catch(() => { });
+
+ if (!session || !session.cachedMatch) {
+ return ctx.reply("❌ Session or cached record expired: Please send /start to try again.", { parse_mode: 'HTML' });
+ }
+
+ try {
+ const cached = session.cachedMatch;
+ const access = await checkUserAccess(userId);
+ const cost = session.serviceType === 'EID_TO_PDF' ? 100 : 120;
+
+ if (!access.hasAccess || (!access.isUnlimited && access.credits < cost)) {
+ return ctx.reply("❌ Insufficient Credits: Aapke paas is record ko download karne ke liye paryapt balance nahi hai. Please add funds.", { parse_mode: 'HTML' });
+ }
+
+ let leftCredits = access.credits;
+ if (!access.isUnlimited) {
+ leftCredits = await deductUserCredit(userId, cost);
+ } else {
+ setCooldown(userId, session.serviceType || 'DOWNLOAD_PDF');
+ }
+
+ const pdfBuffer = Buffer.from(cached.pdf_base64, 'base64');
+ const nameVal = cached.name ? cached.name.toUpperCase() : 'USER';
+ const finalAadhaar = cached.aadhaar_number || 'N/A';
+ const passVal = cached.pdf_password || 'Protected (Locked)';
+
+ let msg = `📄 AADHAAR PDF READY (INSTANT CACHE) 📄\n` +
+ `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
+ `👤 Name: ${nameVal}\n` +
+ `🆔 UID / No: ${finalAadhaar}\n` +
+ `🔑 Password: ${passVal}\n` +
+ `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
+ `💰 Charged: ${access.isUnlimited ? '0 (VIP Pass)' : cost + ' Credits'}\n` +
+ `🪙 Balance: ${access.isUnlimited ? 'Unlimited' : leftCredits + ' Credits'}\n` +
+ `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
+ `⚡ AADHAAR VIP ENGINE ⚡`;
+
+ const safeFileName = `${(nameVal || 'Aadhaar').replace(/[^\w\s-]/gi, '').trim().replace(/\s+/g, '_')}_Aadhaar.pdf`;
+
+ await ctx.deleteMessage().catch(() => { });
+ await ctx.replyWithDocument({ source: pdfBuffer, filename: safeFileName }, { caption: msg, parse_mode: 'HTML' });
+
+ session.step = 'FINISHED';
+ } catch (err) {
+ console.error("Error in CACHE_CONFIRM_YES:", err);
+ ctx.reply("❌ Error downloading cached Aadhaar PDF. Please try again.");
+ }
});
bot.action('CHOOSE_WITH_NAME', async (ctx) => {
[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.