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] @@ -1060,14 +1060,21 @@ async function checkUserAccess(userId) { // Admin bypass: Admin gets unlimited credits if (checkIsAdmin(userId)) { - return { hasAccess: true, isUnlimited: true, credits: 999999, planExpiresAt: new Date(Date.now() + 1000 * 24 * 60 * 60 * 1000) }; - } - - if (!pool) return { hasAccess: false, credits: 0, isUnlimited: false }; + return { + hasAccess: true, + isUnlimited: true, + credits: 999999, + planExpiresAt: new Date(Date.now() + 1000 * 24 * 60 * 60 * 1000), + planStartedAt: new Date(), + createdAt: new Date() + }; + } + + if (!pool) return { hasAccess: false, credits: 0, isUnlimited: false, planExpiresAt: null, planStartedAt: null, createdAt: null }; // Real-time Database Check (No cache for plan/balance to avoid stale expired searches) try { - const res = await pool.query('SELECT credits, plan_type, plan_expires_at FROM users WHERE telegram_id = $1', [userId]); + const res = await pool.query('SELECT credits, plan_type, plan_expires_at, plan_started_at, created_at FROM users WHERE telegram_id = $1', [userId]); let resultData; if (res.rows.length > 0) { const row = res.rows[0]; @@ -1074,3 +1074,4 @@ + const planStarted = row.plan_started_at ? new Date(row.plan_started_at) : (row.created_at ? new Date(row.created_at) : null); const isUnlimited = row.plan_type !== 'credits' && planExpires && planExpires > new Date(); const credits = row.credits || 0; resultData = { @@ -1077,9 +1077,11 @@ isUnlimited, credits, - planExpiresAt: planExpires - }; - } else { - resultData = { hasAccess: false, isUnlimited: false, credits: 0, planExpiresAt: null }; + planExpiresAt: planExpires, + planStartedAt: planStarted, + createdAt: row.created_at ? new Date(row.created_at) : null + }; + } else { + resultData = { hasAccess: false, isUnlimited: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null }; } return applyFreeMode(resultData); @@ -1086,5 +1086,5 @@ console.error("Error in checkUserAccess:", err.message); - return applyFreeMode({ hasAccess: false, isUnlimited: false, credits: 0, planExpiresAt: null }); + return applyFreeMode({ hasAccess: false, isUnlimited: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null }); } } [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.