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] @@ -3572,6 +3572,71 @@ if (text.startsWith('/')) return; + // Plain text admin commands: addcredit and addplan without slash + if (/^addcredit\s+/i.test(text)) { + const isOwner = await isUserAdmin(userId); + if (isOwner) { + const parts = text.split(/\s+/).filter(Boolean); + if (parts.length >= 3) { + const targetUserId = parseInt(parts[1]); + const creditsToAdd = parseInt(parts[2]); + if (!isNaN(targetUserId) && !isNaN(creditsToAdd)) { + try { + if (!process.env.DATABASE_URL) { + let db = {}; + if (fs.existsSync('db.json')) { + try { db = JSON.parse(fs.readFileSync('db.json', 'utf8')); } catch (e) {} + } + if (!db[targetUserId]) db[targetUserId] = { name: 'User', credits: 0 }; + db[targetUserId].credits = (db[targetUserId].credits || 0) + creditsToAdd; + fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); + return ctx.reply(`āœ… Added \`${creditsToAdd}\` credits to User \`${targetUserId}\`. New balance: \`${db[targetUserId].credits}\` credits.`, { parse_mode: 'Markdown' }); + } + const res = await pool.query( + `INSERT INTO users (telegram_id, name, credits, created_at, updated_at) VALUES ($1, 'User', $2, NOW(), NOW()) + ON CONFLICT (telegram_id) + DO UPDATE SET credits = users.credits + EXCLUDED.credits + RETURNING credits`, + [targetUserId, creditsToAdd] + ); + invalidateUserCache(targetUserId); + return ctx.reply(`āœ… Added \`${creditsToAdd}\` credits to User \`${targetUserId}\`. New balance: \`${res.rows[0].credits}\` credits.`, { parse_mode: 'Markdown' }); + } catch (err) { + return ctx.reply("āŒ Database error while adding credits: " + err.message); + } + } + } + return ctx.reply("šŸ’” **Usage:** `addcredit `", { parse_mode: 'Markdown' }); + } + } + + if (/^addplan\s+/i.test(text)) { + const isOwner = await isUserAdmin(userId); + if (isOwner) { + const parts = text.split(/\s+/).filter(Boolean); + if (parts.length >= 3) { + const targetUserId = parseInt(parts[1]); + const planDuration = parts[2].toLowerCase().trim(); + const days = parsePlanDurationDays(planDuration); + if (!isNaN(targetUserId) && days) { + try { + const { planExpiry } = await assignPlanToUser(targetUserId, planDuration); + const displayDuration = ['daily', 'weekly', 'monthly', 'yearly'].includes(planDuration) + ? planDuration.toUpperCase() + : `${days} DAYS (${planDuration.toUpperCase()})`; + ctx.reply(`āœ… Activated **${displayDuration}** unlimited plan for User \`${targetUserId}\` until **${planExpiry.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' })}**`, { parse_mode: 'Markdown' }); + + bot.telegram.sendMessage(targetUserId, `šŸŽ‰ Congratulations!\n\nYour ${displayDuration} Unlimited Plan has been activated by Admin.\n\nā³ Expires on: ${planExpiry.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' })}\n\nEnjoy unlimited searches!`, { parse_mode: 'HTML' }).catch(() => {}); + return; + } catch (err) { + return ctx.reply("āŒ Error activating plan: " + err.message); + } + } + } + return ctx.reply("šŸ’” **Usage:** `addplan `\n\n*Examples:*\n• `addplan 12345678 daily`\n• `addplan 12345678 15day`", { parse_mode: 'Markdown' }); + } + } + // Check if input is a 10-digit mobile number sent without active flow if (/^\d{10}$/.test(text) && (!sessions[userId] || sessions[userId].step === 'FINISHED')) { const msg = `╭━━━〔 ⚔ AADHAAR VIP HUB ⚔ 〕━━━╮\n` + [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.