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] @@ -2253,31 +2253,6 @@ } catch(e) { console.error("Admin check err:", e); return false; } } -async function isUserRetailer(userId) { - if (!process.env.DATABASE_URL) { - const fs = require('fs'); - if (!fs.existsSync('db.json')) return false; - try { - const db = JSON.parse(fs.readFileSync('db.json', 'utf8')); - return !!(db[userId] && db[userId].is_retailer); - } catch (e) { - console.error("Retailer check err:", e); - return false; - } - } else { - try { - const res = await pool.query('SELECT is_retailer FROM users WHERE telegram_id = $1', [userId]); - if (res.rows.length > 0) { - return !!res.rows[0].is_retailer; - } - return false; - } catch (e) { - console.error("Retailer check err:", e); - return false; - } - } -} - bot.command('addplan', async (ctx) => { const senderId = ctx.from.id; const isOwner = await isUserAdmin(senderId); @@ -2303,95 +2303,6 @@ } }); -// Owner command to add a retailer -bot.command('addretailer', async (ctx) => { - const senderId = ctx.from.id; - const isOwner = await isUserAdmin(senderId); - if (!isOwner) { - return; // Silent skip/skip - } - - const args = ctx.message.text.split(' ').slice(1); - if (args.length < 1) { - return ctx.reply("💡 **Usage:** `/addretailer `", { parse_mode: 'Markdown' }); - } - - const targetUserId = parseInt(args[0]); - if (isNaN(targetUserId)) { - return ctx.reply("❌ Invalid user ID."); - } - - try { - if (!process.env.DATABASE_URL) { - const fs = require('fs'); - let db = {}; - if (fs.existsSync('db.json')) { - try { db = JSON.parse(fs.readFileSync('db.json', 'utf8')); } catch (e) { - console.error("Retailer check err:", e); } - } - if (!db[targetUserId]) { - db[targetUserId] = { name: 'User', credits: 0 }; - } - db[targetUserId].is_retailer = true; - fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); - } else { - await pool.query( - `INSERT INTO users (telegram_id, name, credits, is_retailer, created_at, updated_at) VALUES ($1, 'User', 0, true, NOW(), NOW()) - ON CONFLICT (telegram_id) - DO UPDATE SET is_retailer = true`, - [targetUserId] - ); - } - return ctx.reply(`✅ User \`${targetUserId}\` is now designated as a **Retailer**! They can use \`/maya\` command.`, { parse_mode: 'Markdown' }); - } catch (err) { - console.error("Error adding retailer:", err.message); - ctx.reply(`❌ Error designating retailer: ${err.message}`); - } -}); - -// Owner command to remove a retailer -bot.command('removeretailer', async (ctx) => { - const senderId = ctx.from.id; - const isOwner = await isUserAdmin(senderId); - if (!isOwner) { - return; // Silent skip/skip - } - - const args = ctx.message.text.split(' ').slice(1); - if (args.length < 1) { - return ctx.reply("💡 **Usage:** `/removeretailer `", { parse_mode: 'Markdown' }); - } - - const targetUserId = parseInt(args[0]); - if (isNaN(targetUserId)) { - return ctx.reply("❌ Invalid user ID."); - } - - try { - if (!process.env.DATABASE_URL) { - const fs = require('fs'); - let db = {}; - if (fs.existsSync('db.json')) { - try { db = JSON.parse(fs.readFileSync('db.json', 'utf8')); } catch (e) { - console.error("Retailer check err:", e); } - } - if (db[targetUserId]) { - db[targetUserId].is_retailer = false; - fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); - } - } else { - await pool.query( - `UPDATE users SET is_retailer = false WHERE telegram_id = $1`, - [targetUserId] - ); - } - return ctx.reply(`✅ Designated **Retailer** status has been removed from User \`${targetUserId}\`.`, { parse_mode: 'Markdown' }); - } catch (err) { - console.error("Error removing retailer:", err.message); - ctx.reply(`❌ Error removing retailer: ${err.message}`); - } -}); - // Owner command to manually give 120 free credits to all users (and notify them) bot.command('givefree', async (ctx) => { const userId = ctx.from.id; [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.