indrajitghosh20006/HgfhhuybotPublic · Bot Template

ProfileTelegram

AIThis bot provides a command‑based admin interface for managing user balances, products, and resellers. It supports adding balances via UPI or Binance Pay, approving payments, and configuring product details and categories. The bot also handles user role changes, stock uploads, and offers a simple calculator UI for entering amounts. All interactions are handled through short commands and inline keyboards, with no long‑running listeners or external frameworks.

Utilityadminbalanceproductresellerpaymentupi
138 commands0 envUpdated 16h agoCreated Sep 27, 2026
Back to folder

commands/_confirm_reseller_upgrade.js

javascript · 101 lines

Raw
1/**#command2name: /confirm_reseller_upgrade3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 👑 Reseller Upgrade — Confirm button handler14// Balance sufficient -> instant upgrade. Insufficient -> shortfall QR15// (payment completion handled automatically in _onCheck.js).16// =========================================================17 18try {19  var userId = String(user.telegramid);20  var chatId = chat.chatid;21 22  if (Bot.getProperty("is_reseller_" + userId)) {23    Bot.sendMessage("💎 Aap already ek Reseller hain!");24    return;25  }26 27  var price = Number(Bot.getProperty("reseller_upgrade_price") || 0);28  if (!price) {29    Bot.sendMessage("❌ Reseller Upgrade price admin ne abhi set nahi kiya.");30    return;31  }32 33  var unifiedBal = (function () {34    var resBal = 0;35    try { resBal = Number(Libs.ResourcesLib.userRes("balance").value()) || 0; } catch (e) {}36    return resBal;37  })();38 39  function grantReseller(chatIdTarget) {40    Bot.setProperty("is_reseller_" + userId, true, "boolean");41    var congratsText =42      "<blockquote><tg-emoji emoji-id='6102856637343600044'>🎉</tg-emoji> <b>CONGRATULATIONS!</b></blockquote>\n\n" +43      "<tg-emoji emoji-id='6215386799133433653'>👑</tg-emoji> <b>You are now a Reseller!</b>\n\n" +44      "<i>Aapko ab har product/plan par reseller pricing milegi, priority processing, aur reseller-only stock ka access. Enjoy your upgraded status!</i>";45    Api.sendMessage({46      chat_id: chatIdTarget,47      text: congratsText,48      parse_mode: "HTML",49      reply_markup: JSON.stringify({ inline_keyboard: [[{ text: "Explore Shop", callback_data: "/buy_hack", style: "success", icon_custom_emoji_id: "5866053971960929280" }]] })50    });51 52    var ownerId = Bot.getProperty("owner_id") || "7839151435";53    try {54      Api.sendMessage({55        chat_id: ownerId,56        text: "👑 <b>NEW RESELLER!</b>\n👤 <b>User:</b> <code>" + userId + "</code>\n💰 <b>Paid:</b> ₹" + price.toFixed(2),57        parse_mode: "HTML"58      });59    } catch (e) {}60  }61 62  if (unifiedBal >= price) {63    try { Libs.ResourcesLib.userRes("balance").add(-price); } catch (e) {}64    grantReseller(chatId);65  } else {66    var needToPay = price - unifiedBal;67    User.setProperty("buy_reseller_upgrade", true, "boolean");68    User.setProperty("buy_reseller_price", price, "number");69 70    var genText = "<tg-emoji emoji-id='6100657257605763582'>⏳</tg-emoji> <b>Creating order for ₹" + needToPay.toFixed(2) + ", please wait...</b>";71    if (request && request.message) {72      Api.editMessageText({ chat_id: String(chatId), message_id: Number(request.message.message_id), text: genText, parse_mode: "HTML" });73      try {74        Bot.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");75        User.setProperty("gen_msg_id_" + userId, request.message.message_id, "string");76      } catch (e) {}77    } else {78      var genMsg = Api.sendMessage({ chat_id: chatId, text: genText, parse_mode: "HTML" });79      try {80        var gmid = (genMsg && genMsg.result && genMsg.result.message_id) ? genMsg.result.message_id : (genMsg && genMsg.message_id ? genMsg.message_id : null);81        if (gmid) {82          Bot.setProperty("gen_msg_id_" + userId, gmid, "string");83          User.setProperty("gen_msg_id_" + userId, gmid, "string");84        }85      } catch (e) {}86    }87 88    var upi_id = Bot.getProperty("payment_upi_id") || "maidulmidya@fam";89    HTTP.get({90      url: "https://fampay.anujbots.xyz/qr.php?upi=" + encodeURIComponent(upi_id) + "&amount=" + encodeURIComponent(needToPay.toFixed(2)),91      success: "/onQR",92      error: "/onApiError"93    });94  }95 96  var queryId = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;97  if (queryId) { try { Api.answerCallbackQuery({ callback_query_id: String(queryId) }); } catch (e) {} }98 99} catch (err) {100  Bot.sendMessage("⚠️ Error: " + err.message);101}