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/_onContactRecieved.js

javascript Β· 203 lines

Raw
1/**#command2name: /onContactRecieved3answer: 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 53try {54  var userId = user.telegramid;55  var contactData = request && request.message ? request.message.contact : null;56 57  if (!contactData) {58    Bot.sendMessage("⚠️ Contact data nahi mila, dobara try karein.");59    return;60  }61 62  if (String(contactData.user_id) !== String(userId)) {63    Api.sendMessage({64      chat_id: chat.chatid,65      text: "⚠️ <b>Please share your own contact</b> to verify.",66      parse_mode: "HTML",67      reply_markup: JSON.stringify({68        keyboard: [[{ text: "βœ… Verify Account", request_contact: true }]],69        resize_keyboard: true,70        one_time_keyboard: true71      })72    });73    return;74  }75 76  Bot.setProperty("verified_" + userId, true, "boolean");77  User.setProperty("verified_" + userId, true, "boolean");78  // βœ… NEW: Joined date save karo (Profile section me dikhane ke liye)79  if (!Bot.getProperty("joined_date_" + userId)) {80    Bot.setProperty("joined_date_" + userId, new Date().toLocaleDateString("en-IN", { day: "2-digit", month: "short", year: "numeric" }), "string");81  }82 83  var phone = contactData.phone_number || "N/A";84 85  Api.sendMessage({86    chat_id: chat.chatid,87    text: "<blockquote><tg-emoji emoji-id='5330237710655306682'>βœ…</tg-emoji> <b>Account Verified Successfully!</b>\n<tg-emoji emoji-id='6266994443262367483'>😊</tg-emoji> <i>Welcome! Loading your menu...</i></blockquote>",88    parse_mode: "HTML",89    reply_markup: JSON.stringify({ remove_keyboard: true })90  });91 92  var adminId = "7839151435";93  var uName = (user && user.first_name) ? user.first_name : "Unknown";94  var uUsername = (user && user.username) ? "@" + user.username : "No Username";95 96  var adminAlert = "<blockquote>" +97    "<tg-emoji emoji-id='6113743082358841933'>πŸ”°</tg-emoji> <b>NEW USER VERIFIED</b>\n" +98    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +99    "πŸ‘€ <b>Name:</b> " + uName + " (" + uUsername + ")\n" +100    "πŸ†” <b>User ID:</b> <code>" + userId + "</code>\n" +101    "πŸ“ž <b>Phone:</b> <code>" + phone + "</code>\n" +102    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +103    "βœ… <i>Status: Verified via Contact Share</i>" +104    "</blockquote>";105 106  Api.sendMessage({ chat_id: adminId, text: adminAlert, parse_mode: "HTML" });107 108  // πŸ”— PENDING DEEP LINK -> LOADING THEN SHOW PRODUCT PLANS (via HTTP delay)109  var pendingSlug = Bot.getProperty("pending_deeplink_" + userId) || User.getProperty("pending_deeplink_" + userId) || "";110 111  if (pendingSlug !== "") {112    var productList = Bot.getProperty("stored_products") || [];113    var matchedIdx = -1;114 115    for (var p = 0; p < productList.length; p++) {116      var slug = String(productList[p].name || "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");117      if (slug === pendingSlug.toLowerCase()) {118        matchedIdx = p;119        break;120      }121    }122 123    Bot.setProperty("pending_deeplink_" + userId, null, "string");124    User.setProperty("pending_deeplink_" + userId, null, "string");125 126    if (matchedIdx > -1) {127      // ⏳ STEP 1: LOADING MESSAGE128      var loadingText = "<blockquote>" +129        "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Loading your product</b><tg-emoji emoji-id='6193006377389005214'>...</tg-emoji>\n" +130        "<i>Please wait a moment</i>" +131        "</blockquote>";132 133      var loadingMsg = Api.sendMessage({134        chat_id: chat.chatid,135        text: loadingText,136        parse_mode: "HTML"137      });138 139      var loadingMsgId = (loadingMsg && loadingMsg.result && loadingMsg.result.message_id) ? loadingMsg.result.message_id : null;140 141      // πŸ’Ύ STEP 2: Save state for the delayed callback142      User.setProperty("dl_wait_msgid", loadingMsgId, "number");143      User.setProperty("dl_wait_prodidx", matchedIdx, "number");144      User.setProperty("dl_wait_chatid", String(chat.chatid), "string");145 146      // ⏳ STEP 3: 4-SECOND DELAY VIA HTTP CALLBACK (setTimeout ke bajaye)147      HTTP.get({148        url: "https://httpbin.org/delay/4",149        success: "/onDeepLinkPlanShow",150        error: "/onDeepLinkPlanShow"151      });152 153      return;154    }155  }156 157  // βœ… Koi pending deep-link nahi -> DIRECT MAIN MENU158  var userBal2 = "0.00";159  try {160    var res2 = 0;161    if (Libs && Libs.ResourcesLib) { res2 = Libs.ResourcesLib.userRes("balance").value() || 0; }162    var adminBal2 = Bot.getProperty("balance" + userId) || 0;163    userBal2 = (Number(res2) + Number(adminBal2)).toFixed(2);164  } catch (balErr2) {165    var fallbackBal2 = Bot.getProperty("balance" + userId) || 0;166    userBal2 = Number(fallbackBal2).toFixed(2);167  }168 169  var welcomeMessage2 =170    "<tg-emoji emoji-id=\"6266967801580231067\">πŸ’Ž</tg-emoji> <tg-emoji emoji-id=\"5866053971960929280\">πŸͺ</tg-emoji> <b>β€” 𝙄𝙂 π™Žπ™π™Šπ™π™€ β€”</b> <tg-emoji emoji-id=\"5866053971960929280\">πŸͺ</tg-emoji> <tg-emoji emoji-id=\"6266967801580231067\">πŸ’Ž</tg-emoji>\n\n" +171    "<tg-emoji emoji-id=\"6093677128295914531\">πŸŽ‰</tg-emoji> <b>Hello, " + ((user && user.first_name) ? user.first_name.toUpperCase() : "RESELLER") + "!</b>\n\n" +172    "<tg-emoji emoji-id=\"6080228009439141516\">πŸ’§</tg-emoji> <b>Genuine, limited-stock books. Instant delivery.</b>\n\n" +173    "<tg-emoji emoji-id=\"6093591495237967001\">🌐</tg-emoji> Wide product catalog\n" +174    "<tg-emoji emoji-id=\"6215386799133433653\">πŸ”‘</tg-emoji> Instant delivery on payment\n" +175    "<tg-emoji emoji-id=\"6312263493051489212\">πŸ’°</tg-emoji> Multiple payment gateways\n" +176    "<tg-emoji emoji-id=\"6100170496077204999\">πŸ‘‘</tg-emoji> 24/7 admin support\n\n" +177    "<i>Balance: β‚Ή" + userBal2 + "</i>\n\n" +178    "<i>Tap any button below to begin:</i> <tg-emoji emoji-id='6057415823222379852'>πŸ‘‡</tg-emoji>";179 180  var multiColorKeyboard2 = [181    [{ text: "Shop Now", callback_data: "/buy_hack", style: "primary", icon_custom_emoji_id: "5866053971960929280" }],182    [183      { text: "Profile", callback_data: "/profile", style: "primary", icon_custom_emoji_id: "5260399854500191689" },184      { text: "Add Balance", callback_data: "/addfund", style: "success", icon_custom_emoji_id: "6147815702163102310" }185    ],186    [187      { text: "My Keys", callback_data: "/mykey", style: "primary", icon_custom_emoji_id: "6113743082358841933" },188      { text: "How to use", callback_data: "/how", style: "danger", icon_custom_emoji_id: "6080214566191505147" }189    ],190    [{ text: "Refer & Earn", callback_data: "/referral", style: "success", icon_custom_emoji_id: "6093677128295914531" }],191        [{ text: "Support", callback_data: "/support", style: "danger", icon_custom_emoji_id: "5436113877181941026" }]192  ];193 194  Api.sendMessage({195    chat_id: chat.chatid,196    text: welcomeMessage2,197    parse_mode: "HTML",198    reply_markup: JSON.stringify({ inline_keyboard: multiColorKeyboard2 })199  });200 201} catch (err) {202  Bot.sendMessage("⚠️ System Error: " + err.message);203}