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] @@ -1217,263 +1217,6 @@ } } -// Backward compatibility aliases -async function getDailyFreeNumSearches(userId) { - const isAvail = await getDailyFreeSearchAvailable(userId); - return isAvail ? 0 : 1; -} - -async function incrementDailyFreeNumSearches(userId) { - await markDailyFreeSearchUsed(userId); - return 1; -} - -async function handleNumLookup(ctx, mobile) { - const userId = ctx.from.id; - - // Membership check - const isMember = await checkChannelMembership(ctx, userId); - if (!isMember) { - const access = await checkUserAccess(userId); - let forceJoinMsg = `⚠️ Membership Required / चैनल ज्वाइन करना अनिवार्य है ⚠️\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Bot use karne ke liye hamara channel join karna mandatory hai!\n\n` + - `(You must join our telegram channel to continue using the bot!)\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━`; - - let missing = membershipCache.get(userId)?.missingChannels; - if (!missing || missing.length === 0) { - missing = [ - { id: '-1003813331448', link: 'https://t.me/MayaXDev', label: '📢 MayaXDev' }, - { id: '-1003900141964', link: 'https://t.me/NumberBaaz', label: '📢 NumberBaaz' } - ]; - } - const keyboard = missing.map(ch => [{ text: ch.label.replace(/[^a-zA-Z0-9 ]/g, "").trim() || "Join Channel", url: ch.link, style: "primary" }]); - keyboard.push([{ text: 'Verify Join', callback_data: 'VERIFY_CHANNEL_FSUB', style: 'success' }]); - - return ctx.reply(forceJoinMsg, { - parse_mode: 'HTML', - ...Markup.inlineKeyboard(keyboard) - }); - } - - // Cooldown check - const cooldown = checkCooldown(userId, 'NUMBER_TO_INFO'); - if (cooldown.active) { - return ctx.reply(`⏳ Cooldown Active: Please wait ${cooldown.timeLeft}s before requesting this service again.`, { parse_mode: 'HTML' }); - } - - // 1. Check if cached results exist in Redis - let cachedData = null; - if (redisClient) { - try { - const cachedVal = await redisClient.get(`num_cache:${mobile}`); - if (cachedVal) { - cachedData = JSON.parse(cachedVal); - } - } catch (e) { - console.error("Error reading from Redis cache:", e.message); - } - } - - // If cached data exists, process immediately without credit checks or deduction! - if (cachedData && cachedData.result && Array.isArray(cachedData.result.results)) { - const results = cachedData.result.results; - const total = results.length; - - // Generate session ID for Web App - const sessionId = crypto.randomUUID(); - if (redisClient) { - try { - await redisClient.set(`num_session:${sessionId}`, JSON.stringify({ - mobile: mobile, - records: results, - createdAt: Date.now() - }), 'EX', 600); - } catch (e) { - console.error("Redis session save error:", e.message); - } - } - - // Calculate stats - const aadhaars = new Set(results.map(r => r.id).filter(id => id)).size; - const mobiles = new Set(results.flatMap(r => [r.MOBILE, r.alt].filter(m => m))).size; - const addresses = new Set(results.map(r => r.ADDRESS).filter(addr => addr)).size; - - let responseText = `🛡️ ${toMono("AADHAAR PREMIUM SERVICES")}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `📱 ─── ${toMono("NUMBER INFO REPORT")} ─── 📱\n\n` + - `🔍 Searched Term: ${mobile}\n` + - `📊 Total Records: ${total}\n` + - `💳 Aadhaar IDs: ${aadhaars}\n` + - `📞 Mobile Numbers: ${mobiles}\n` + - `🏠 Addresses Found: ${addresses}\n\n` + - `
⚡ Cached Result\n` + - `🪙 No credits were deducted (Search was cached).
\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `⏳ Web App link is valid for 10 minutes only!`; - - const webAppUrl = `https://apikendra.cc/num-view/${sessionId}`; - const keyboard = Markup.inlineKeyboard([ - [{ text: 'Open Web App (View & Copy)', web_app: { url: webAppUrl }, style: 'primary' }] - ]); - - return ctx.reply(responseText, { parse_mode: 'HTML', ...keyboard }); - } - - // Access check (Credits or Subscription or Daily Free Search) - const access = await checkUserAccess(userId); - - if (!access.hasAccess) { - const unauthorizedMsg = `🛡️ ${toMono("AADHAAR PREMIUM SERVICES")}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `👤 Session Info:\n` + - `• User: ${ctx.from?.first_name || 'User'}\n` + - `• ID: ${userId}\n` + - `• Balance: ${access.credits} Credits ${CREDIT_EMOJI}\n` + - `• Daily Free Search: Used Today (Resets 12:00 AM IST) ⏳\n\n` + - `
⚠️ Access Limit / Limit Restricted:\n` + - `Aapka aaj ka 1 Daily Free Search use ho chuka hai aur aapke paas credits nahi hain. Aage search karne ke liye credits khareedein (Cost: 1 Credit ${CREDIT_EMOJI} per search = ₹60).\n\n` + - `(Daily free search exhausted. Please add funds to proceed.)
\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━`; - - return ctx.reply(unauthorizedMsg, { - parse_mode: 'HTML', - ...Markup.inlineKeyboard([ - [ - { text: '🛒 Buy Now', callback_data: 'BUY_CREDITS_MENU', style: 'primary' }, - { text: 'Free Credits', callback_data: 'EARN_FREE_CREDIT', style: 'success' } - ], - [ - { text: 'Support', url: 'https://t.me/EverythingBypass', style: 'primary' } - ] - ]) - }); - } - - // Loader message - const loaderMsg = await ctx.reply('🔍 Fetching number info... Please wait.', { parse_mode: 'HTML' }); - - try { - const url = `https://info.apikendra.cc/search/any?q=${mobile}`; - const response = await fetchWithAgent(url); - const textResp = await response.text(); - let data = {}; - try { - data = JSON.parse(textResp); - } catch (e) { - console.error("Number API returned non-JSON:", textResp.substring(0, 100)); - } - - // Normalize response from new API to match old expected structure - if (data.status === "success" && Array.isArray(data.data)) { - data = { - success: true, - result: { - success: true, - results: data.data.map(item => ({ - MOBILE: item.mobile, - NAME: item.name, - fname: item.fname, - ADDRESS: item.address, - alt: item.alt, - circle: item.circle, - id: item.id, - email: item.email - })) - } - }; - } - - // Delete loader message - await ctx.telegram.deleteMessage(ctx.chat.id, loaderMsg.message_id).catch(() => {}); - - if (data.success && data.result && data.result.success && Array.isArray(data.result.results) && data.result.results.length > 0) { - // Save to cache (EX: 600s = 10 mins) - if (redisClient) { - try { - await redisClient.set(`num_cache:${mobile}`, JSON.stringify(data), 'EX', 600); - } catch (e) { - console.error("Redis cache save error:", e.message); - } - } - - const results = data.result.results; - const total = results.length; - - // Success! Perform access deduction/charge - let deductionLog = ''; - if (access.isUnlimited) { - deductionLog = `💳 Plan: Unlimited 💎 (No credits deducted)`; - } else if (access.hasFreeSearch) { - await markDailyFreeSearchUsed(userId); - deductionLog = `🎁 Charged: 0 (Daily Free Search Used: 1/1)\n🪙 Credits Balance: ${access.credits} Credits ${CREDIT_EMOJI}`; - } else { - const newBal = await deductUserCredit(userId, 1); - deductionLog = `💰 Credits Charged: 1 Credit ${CREDIT_EMOJI}\n🪙 Remaining Balance: ${newBal} Credits ${CREDIT_EMOJI}`; - } - - // set cooldown - setCooldown(userId, 'NUMBER_TO_INFO'); - - // Generate session ID - const sessionId = crypto.randomUUID(); - - // Store results in Redis (with 10 mins expiry = 600s) - if (redisClient) { - try { - await redisClient.set(`num_session:${sessionId}`, JSON.stringify({ - mobile: mobile, - records: results, - createdAt: Date.now() - }), 'EX', 600); - } catch (e) { - console.error("Redis session save error:", e.message); - } - } - - // Calculate stats - const aadhaars = new Set(results.map(r => r.id).filter(id => id)).size; - const mobiles = new Set(results.flatMap(r => [r.MOBILE, r.alt].filter(m => m))).size; - const addresses = new Set(results.map(r => r.ADDRESS).filter(addr => addr)).size; - - let responseText = `╭━━━〔 📱 NUMBER INTELLIGENCE REPORT 📱 〕━━━╮\n` + - `┃ \n` + - `┃ 🔍 Searched Term : ${mobile}\n` + - `┃ 📊 Total Records : ${total}\n` + - `┃ 💳 Aadhaar Linked : ${aadhaars}\n` + - `┃ 📞 Mobile Numbers : ${mobiles}\n` + - `┃ 🏠 Addresses Found: ${addresses}\n` + - `┃ \n` + - `┃ 🪙 Status : ${deductionLog}\n` + - `╰━━━━━━━━━━━━━━━━━━━━━━━━━━━━╯\n` + - `⏳ Web App link is valid for 10 minutes only.`; - - const webAppUrl = `https://apikendra.cc/num-view/${sessionId}`; - const keyboard = Markup.inlineKeyboard([ - [{ text: 'Open Web App (View & Copy)', web_app: { url: webAppUrl }, style: 'primary' }] - ]); - - await ctx.reply(responseText, { parse_mode: 'HTML', ...keyboard }); - - // save search record - const firstResultName = results[0]?.NAME || 'Info Search'; - await saveSearchRecord(userId, 'NUMBER_TO_INFO', firstResultName, mobile, null, null, null, null).catch(err => { - console.error("Error saving search record:", err.message); - }); - - } else { - // No results found - await ctx.reply(`❌ No records found / कोई रिकॉर्ड नहीं मिला\n\nNo records found for the number ${mobile}. No credits were deducted.`, { parse_mode: 'HTML' }); - } - } catch (error) { - console.error("Number lookup error:", error); - // Delete loader message in case of error - await ctx.telegram.deleteMessage(ctx.chat.id, loaderMsg.message_id).catch(() => {}); - await ctx.reply('❌ An error occurred while fetching information. Please try again.', { parse_mode: 'HTML' }); - } -} - async function isUserNew(userId) { if (!process.env.DATABASE_URL) { const fs = require('fs'); [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. We did our best to apply changes despite some inaccuracies. Double check if the edit applied is what you intended.