indrajitghosh20006/Igstore_01botPublic Β· Bot Template

ProfileTelegram

AIThe bot provides an admin interface for a digital store, allowing the owner or co‑admins to add balances, products, plans, and categories. It supports payment workflows via UPI and Binance Pay, automatically generating QR codes and handling manual approval of deposits. The code patches inline keyboards to use premium emoji icons and includes helper functions for user and bot properties. Overall, it serves as a commerce management tool for a Telegram-based storefront.

Commercestoreadminbalanceproductplancategory
170 commands0 envUpdated 7h agoCreated Oct 30, 2026
Back to folder

commands/_setmemberprice.js

javascript Β· 143 lines

Raw
1/**#command2name: /setmemberprice3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// PREMIUM BUTTON ICONS13(function(){14  try {15    if (!JSON.__premiumPatched) {16      var __origStringify = JSON.stringify;17      JSON.stringify = function(value, replacer, space) {18        try {19          if (value && value.inline_keyboard && Array.isArray(value.inline_keyboard)) {20            var premiumIds = [21              "6143444134125379822",22              "6091379307907652768",23              "6147534454819661264",24              "6147817325660741985",25              "6235683689292897318",26              "6102856637343600044"27            ];28            var rows = value.inline_keyboard.map(function(row, ri) {29              if (!Array.isArray(row)) return row;30              return row.map(function(btn, bi) {31                if (!btn || typeof btn !== "object") return btn;32                var copy = {};33                for (var k in btn) copy[k] = btn[k];34                if (!copy.icon_custom_emoji_id) copy.icon_custom_emoji_id = premiumIds[(ri + bi) % premiumIds.length];35                return copy;36              });37            });38            var cloned = {};39            for (var key in value) cloned[key] = value[key];40            cloned.inline_keyboard = rows;41            return __origStringify.call(JSON, cloned, replacer, space);42          }43        } catch (e) {}44        return __origStringify.call(JSON, value, replacer, space);45      };46      JSON.__premiumPatched = true;47    }48  } catch (e) {}49})();50 51 52 53// πŸ‘€ MEMBER-SPECIFIC CUSTOM PRICE54// Usage: /setmemberprice USER_ID | PRODUCT NAME | DURATION | PRICE55// Duration supports: 1h, 2h ... 16h, 1d, 2d, 5d, 11d, etc.56// This does NOT change global normal/reseller prices.57 58try {59  var ownerId = Bot.getProperty("owner_id") || "7839151435";60  var currentChatId = String(chat.chatid);61  var isCoAdmin = Bot.getProperty("co_admin_" + currentChatId);62  if (currentChatId !== String(ownerId) && !isCoAdmin) {63    Bot.sendMessage("❌ Access denied: Admin only.");64    return;65  }66 67  var input = params ? String(params).trim() : "";68  if (!input) {69    Bot.sendMessage(70      "<blockquote>πŸ‘€ <b>MEMBER CUSTOM PRICE</b></blockquote>\n\n" +71      "<b>Format:</b>\n<code>/setmemberprice USER_ID | PRODUCT NAME | DURATION | PRICE</code>\n\n" +72      "<b>Examples:</b>\n" +73      "<code>/setmemberprice 123456789 | PRIME HOOK | 1h | 50</code>\n" +74      "<code>/setmemberprice 123456789 | PRIME HOOK | 16h | 120</code>\n" +75      "<code>/setmemberprice 123456789 | PRIME HOOK | 1d | 80</code>\n" +76      "<code>/setmemberprice 123456789 | PRIME HOOK | 11d | 400</code>\n\n" +77      "<i>Global price unchanged rahega; custom price sirf is member par lagega.</i>",78      { parse_mode: "HTML" }79    );80    return;81  }82 83  var parts = input.split("|");84  if (parts.length !== 4) {85    Bot.sendMessage("⚠️ 4 fields chahiye: <code>USER_ID | PRODUCT | DURATION | PRICE</code>", { parse_mode: "HTML" });86    return;87  }88 89  var targetId = parts[0].trim();90  var productName = parts[1].trim();91  var duration = parts[2].trim().replace(/\s+/g, " ");92  var customPrice = Number(parts[3].trim());93 94  if (!/^\d+$/.test(targetId)) {95    Bot.sendMessage("❌ USER_ID numeric Telegram ID hona chahiye. Example: <code>123456789</code>", { parse_mode: "HTML" });96    return;97  }98  if (!productName) {99    Bot.sendMessage("❌ Product name empty nahi ho sakta.");100    return;101  }102  if (!duration) {103    Bot.sendMessage("❌ Duration required hai. Example: <code>1h</code>, <code>16h</code>, <code>1d</code>, <code>11d</code>", { parse_mode: "HTML" });104    return;105  }106  if (!isFinite(customPrice) || customPrice < 0) {107    Bot.sendMessage("❌ Valid price enter karein. Price 0 ya usse zyada hona chahiye.");108    return;109  }110 111  // Normalize only the numeric/unit part. Custom API suffixes are not used for this command.112  var m = duration.toLowerCase().match(/^([0-9]+(?:\.[0-9]+)?)\s*(h|hr|hrs|hour|hours|d|day|days)$/);113  if (!m) {114    Bot.sendMessage("❌ Duration format invalid. Use <code>1h</code>, <code>2h</code>, <code>16h</code>, <code>1d</code>, <code>2d</code>, <code>11d</code> etc.", { parse_mode: "HTML" });115    return;116  }117 118  var value = m[1];119  var unit = /^h/.test(m[2]) ? "hour" : "day";120  var suffix = unit === "day" ? value : value + "_hour";121  var cleanProduct = productName.toUpperCase().replace(/\s+/g, " ").trim();122  var keyProduct = cleanProduct.replace(/[^A-Z0-9_-]/g, "_");123  var key = "member_custom_price_" + targetId + "_" + keyProduct + "_" + suffix;124 125  Bot.setProperty(key, customPrice, "number");126 127  var profile = Bot.getProperty("user_profile_" + targetId) || {};128  var displayName = profile.first_name || profile.name || "Member";129  var displayUsername = profile.username ? "@" + String(profile.username).replace(/^@/, "") : "";130 131  Bot.sendMessage(132    "βœ… <b>Member price updated</b>\n\n" +133    "πŸ‘€ <b>Member:</b> " + displayName + (displayUsername ? " (" + displayUsername + ")" : "") + "\n" +134    "πŸ†” <b>User ID:</b> <code>" + targetId + "</code>\n" +135    "πŸ“¦ <b>Product:</b> <code>" + cleanProduct + "</code>\n" +136    "⏱️ <b>Duration:</b> <code>" + value + " " + (unit === "hour" ? (Number(value) === 1 ? "Hour" : "Hours") : (Number(value) === 1 ? "Day" : "Days")) + "</code>\n" +137    "πŸ’° <b>Member Price:</b> β‚Ή<code>" + customPrice.toFixed(2) + "</code>\n\n" +138    "ℹ️ Global product price change nahi hua hai. Sirf is member ke liye custom price apply hoga.",139    { parse_mode: "HTML" }140  );141} catch (err) {142  Bot.sendMessage("⚠️ Member price error: <code>" + String(err.message).replace(/</g, "&lt;") + "</code>", { parse_mode: "HTML" });143}