amanjha18v/AMAN_SHOPS_BOTPublic · Bot Template
AIAMAN SHOP STORE appears to be a Telegram automation bot. Commands include /*, /addbal, /addbal_all, /addbal_binance, /addbal_binance_approve, /addbal_binance_paid, /addbal_upi, /addcat_id. Observed in code: messaging, http, libs, keyboards, payments.
Utilityutility
132 commands0 envUpdated 7h agoCreated Sep 4, 2026
commands/_rembal.js
javascript · 148 lines
1/**#command2name: /rembal3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// Remove balance from ONE specific Telegram user.13// Usage:14// /rembal USER_ID|AMOUNT15// /rembal USER_ID|ALL16// Button flow: /rembal -> asks for USER_ID|AMOUNT17 18var adminId = String(Bot.getProperty("owner_id") || "5191323229");19var requesterId = String(user.telegramid);20var coAdmin = Bot.getProperty("co_admin_" + requesterId);21 22if (requesterId !== adminId && !coAdmin) {23 Bot.sendMessage("❌ You are not authorized to use this command.");24 return;25}26 27// Safely acknowledge callback only when request exists.28try {29 if (typeof request !== "undefined" && request && request.id) {30 HTTP.post({31 url: "https://api.telegram.org/bot" + bot.token + "/answerCallbackQuery",32 body: { callback_query_id: request.id }33 });34 }35} catch (e) {}36 37var input = "";38try {39 if (typeof message !== "undefined" && message) {40 input = String(message).trim();41 if (input.indexOf(" ") !== -1) input = input.substring(input.indexOf(" ") + 1).trim();42 }43} catch (e) {}44 45// If opened from the Remove Balance button, ask for target + amount.46if (!input) {47 User.setProperty("rembal_step", "waiting_input", "string");48 Bot.sendMessage(49 "<tg-emoji emoji-id='5409048419211682843'>💵</tg-emoji> <b>Remove Balance</b>\n\n" +50 "<i>Send User ID and amount:</i>\n" +51 "<code>USER_ID|AMOUNT</code>\n\n" +52 "Example: <code>5191323229|50</code>\n" +53 "For full balance: <code>5191323229|ALL</code>",54 {parse_mode: "HTML"}55 );56 return;57}58 59var parts = input.split("|");60var targetId = String(parts[0] || "").trim();61var amountText = String(parts.slice(1).join("|") || "").trim();62 63if (!/^\d+$/.test(targetId) || !amountText) {64 Bot.sendMessage("❌ <b>Invalid format.</b>\nUse: <code>USER_ID|AMOUNT</code>", {parse_mode: "HTML"});65 return;66}67 68try {69 var resource = Libs.ResourcesLib.anotherUserRes("balance", targetId);70 var resourceBalance = Number(resource.value() || 0);71 var propertyKey = "balance" + targetId;72 var propertyBalance = Number(Bot.getProperty(propertyKey) || 0);73 74 if (!isFinite(resourceBalance) || resourceBalance < 0) resourceBalance = 0;75 if (!isFinite(propertyBalance) || propertyBalance < 0) propertyBalance = 0;76 77 var total = resourceBalance + propertyBalance;78 var removeAmount;79 80 if (amountText.toUpperCase() === "ALL") {81 removeAmount = total;82 } else {83 removeAmount = Number(amountText);84 if (!isFinite(removeAmount) || removeAmount <= 0) {85 Bot.sendMessage("❌ <b>Invalid amount.</b> Enter a positive number.", {parse_mode: "HTML"});86 return;87 }88 }89 90 if (removeAmount <= 0) {91 Bot.sendMessage("⚠️ <b>This user has no balance.</b>", {parse_mode: "HTML"});92 return;93 }94 95 if (removeAmount > total + 0.000001) {96 Bot.sendMessage(97 "❌ <b>Insufficient balance.</b>\n\n" +98 "User ID: <code>" + targetId + "</code>\n" +99 "Current: <code>₹" + total.toFixed(2) + "</code>\n" +100 "Requested: <code>₹" + removeAmount.toFixed(2) + "</code>",101 {parse_mode: "HTML"}102 );103 return;104 }105 106 // Remove from the same two stores used by this bot's balance display/purchase flow.107 // Property wallet is reduced first, then ResourcesLib for any remainder.108 var fromProperty = Math.min(propertyBalance, removeAmount);109 var newProperty = Math.max(0, propertyBalance - fromProperty);110 Bot.setProperty(propertyKey, Number(newProperty.toFixed(2)), "number");111 112 var remaining = removeAmount - fromProperty;113 if (remaining > 0.000001) {114 resource.remove(Math.min(resourceBalance, remaining));115 }116 117 // Clear the admin's Remove Balance step after a successful operation.118 try { User.setProperty("rembal_step", null, "string"); } catch (e) {}119 120 var remainingBalance = Math.max(0, total - removeAmount);121 122 Bot.sendMessage(123 "✅ <b>Balance Removed Successfully</b>\n\n" +124 "👤 User ID: <code>" + targetId + "</code>\n" +125 "💸 Removed: <code>₹" + removeAmount.toFixed(2) + "</code>\n" +126 "💰 Remaining: <code>₹" + remainingBalance.toFixed(2) + "</code>",127 {parse_mode: "HTML"}128 );129 130 try {131 Api.sendMessage({132 chat_id: targetId,133 text:134 "<blockquote>" +135 "<tg-emoji emoji-id='5893163582194978381'>❌</tg-emoji> Admin removed: ₹" + removeAmount.toFixed(2) + "\n" +136 "<tg-emoji emoji-id='6071272104978814192'>😞</tg-emoji> Balance updated\n" +137 "<tg-emoji emoji-id='5257963315258204021'>ℹ️</tg-emoji> Remaining: ₹" + remainingBalance.toFixed(2) +138 "</blockquote>",139 parse_mode: "HTML"140 });141 } catch (e) {}142 143} catch (err) {144 Bot.sendMessage(145 "⚠️ <b>Remove Balance Error:</b> " + String(err && err.message ? err.message : err),146 {parse_mode: "HTML"}147 );148}