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] @@ -1014,8 +1014,13 @@ } async function checkUserAccess(userId) { - // Admin bypass: Admin gets unlimited credits - if (checkIsAdmin(userId)) { + const role = await getUserRole(userId); + const isOwnerRole = (role === 'owner'); + const isAdminRole = (role === 'admin' || isOwnerRole || checkIsAdmin(userId)); + + // Admin / Owner bypass: Admin and Owner get unlimited credits + if (isAdminRole) { + const effectiveRole = role === 'owner' ? 'owner' : 'admin'; return { hasAccess: true, isUnlimited: true, @@ -1022,3 +1022,5 @@ + isOwner: isOwnerRole, + role: effectiveRole, hasFreeSearch: true, credits: 999999, planExpiresAt: new Date(Date.now() + 1000 * 24 * 60 * 60 * 1000), @@ -1025,7 +1025,7 @@ createdAt: new Date(), subscriptionDuration: 'Lifetime (No Expiry)', - subscriptionPaymentMethod: '👑 Admin VIP Pass', - subscriptionAmount: '₹0 (Master)' + subscriptionPaymentMethod: isOwnerRole ? '👑 Owner VIP Pass' : '🛡️ Admin VIP Pass', + subscriptionAmount: '₹0 (VIP)' }; } @@ -1038,6 +1038,8 @@ hasFreeSearch, isUnlimited: false, isAdmin: false, + isOwner: false, + role: 'user', planExpiresAt: null, planStartedAt: null, createdAt: null, @@ -1048,7 +1048,7 @@ // Real-time Database Check try { - const res = await pool.query('SELECT credits, plan_type, plan_expires_at, plan_started_at, subscription_duration, subscription_payment_method, subscription_amount, created_at, last_free_search_date FROM users WHERE telegram_id = $1', [userId]); + const res = await pool.query('SELECT credits, plan_type, plan_expires_at, plan_started_at, subscription_duration, subscription_payment_method, subscription_amount, created_at, last_free_search_date, role FROM users WHERE telegram_id = $1', [userId]); let resultData; if (res.rows.length > 0) { const row = res.rows[0]; @@ -1062,6 +1062,8 @@ hasAccess: isUnlimited || hasFreeSearch || credits > 0, isUnlimited, isAdmin: false, + isOwner: false, + role: row.role || 'user', hasFreeSearch, credits, planExpiresAt: planExpires, @@ -1071,7 +1071,7 @@ createdAt: row.created_at ? new Date(row.created_at) : null }; } else { - resultData = { hasAccess: false, isUnlimited: false, isAdmin: false, hasFreeSearch: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null, subscriptionDuration: null, subscriptionPaymentMethod: null, subscriptionAmount: null }; + resultData = { hasAccess: false, isUnlimited: false, isAdmin: false, isOwner: false, role: 'user', hasFreeSearch: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null, subscriptionDuration: null, subscriptionPaymentMethod: null, subscriptionAmount: null }; } return applyFreeMode(resultData); @@ -1078,5 +1078,5 @@ console.error("Error in checkUserAccess:", err.message); - return applyFreeMode({ hasAccess: false, isUnlimited: false, isAdmin: false, hasFreeSearch: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null, subscriptionDuration: null, subscriptionPaymentMethod: null, subscriptionAmount: null }); + return applyFreeMode({ hasAccess: false, isUnlimited: false, isAdmin: false, isOwner: false, role: 'user', hasFreeSearch: false, credits: 0, planExpiresAt: null, planStartedAt: null, createdAt: null, subscriptionDuration: null, subscriptionPaymentMethod: null, subscriptionAmount: null }); } } @@ -1083,6 +1083,6 @@ async function getUserCredits(userId, name = 'User') { - // Admin bypass: Admin gets unlimited credits - if (checkIsAdmin(userId)) { + // Admin & Owner bypass: Admin gets unlimited credits + if (checkIsAdmin(userId) || (await isUserAdmin(userId))) { return 999999; } [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.