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] @@ -1117,58 +1117,15 @@ } } -// Number Info Lookup Helpers -const dailyFreeSearchesFallback = {}; - -function cleanAddress(addr) { - if (!addr) return 'N/A'; - return addr.replace(/!+/g, ', ').replace(/,\s*,/g, ',').trim(); -} - +// Backward compatibility aliases async function getDailyFreeNumSearches(userId) { - const now = new Date(); - const istTime = new Date(now.getTime() + (5.5 * 60 * 60 * 1000)); - const dateStr = `${istTime.getUTCFullYear()}-${istTime.getUTCMonth() + 1}-${istTime.getUTCDate()}`; - const redisKey = `num_free_limit:${userId}:${dateStr}`; - - let count = 0; - if (redisClient) { - try { - const val = await redisClient.get(redisKey); - if (val !== null) { - count = parseInt(val, 10); - } - } catch (e) { - console.error("Redis error fetching daily free searches:", e); - } - } else { - const localKey = `${userId}:${dateStr}`; - count = dailyFreeSearchesFallback[localKey] || 0; - } - return count; + const isAvail = await getDailyFreeSearchAvailable(userId); + return isAvail ? 0 : 1; } async function incrementDailyFreeNumSearches(userId) { - const now = new Date(); - const istTime = new Date(now.getTime() + (5.5 * 60 * 60 * 1000)); - const dateStr = `${istTime.getUTCFullYear()}-${istTime.getUTCMonth() + 1}-${istTime.getUTCDate()}`; - const redisKey = `num_free_limit:${userId}:${dateStr}`; - - if (redisClient) { - try { - const val = await redisClient.incr(redisKey); - if (val === 1) { - await redisClient.expire(redisKey, 86400); // 24 hours - } - return val; - } catch (e) { - console.error("Redis error incrementing daily free searches:", e); - } - } - - const localKey = `${userId}:${dateStr}`; - dailyFreeSearchesFallback[localKey] = (dailyFreeSearchesFallback[localKey] || 0) + 1; - return dailyFreeSearchesFallback[localKey]; + await markDailyFreeSearchUsed(userId); + return 1; } async function handleNumLookup(ctx, mobile) { [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.