kkapil9112/Hguuuuuv45botPublic · Bot Template

AITelegram commerce bot for an admin-managed digital store: admins create categories, products, time-based plans, stock entries and license keys, and can grant reseller roles or adjust user balances. End users can view their balance, start a deposit flow with an inline amount keypad, apply coupon codes, and navigate back to the store menu. It uses Bot properties for product/stock/coupon data and Libs.ResourcesLib for per-user balances.

Commercecommerceshopreselleradmin-panelbalanceproduct-management
ProfileTelegram
102 commands0 envUpdated 29d agoCreated Aug 7, 2026
Back to folder

commands/_onContactRecieved.js

javascript · 162 lines

Raw
1/**#command2name: /onContactRecieved3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  var userId = user.telegramid;14  var contactData = request && request.message ? request.message.contact : null;15 16  if (!contactData) {17    Bot.sendMessage("⚠️ Contact data nahi mila, dobara try karein.");18    return;19  }20 21  if (String(contactData.user_id) !== String(userId)) {22    Api.sendMessage({23      chat_id: chat.chatid,24      text: "⚠️ <b>Please share your own contact</b> to verify.",25      parse_mode: "HTML",26      reply_markup: JSON.stringify({27        keyboard: [[{ text: "✅ Verify Account", request_contact: true }]],28        resize_keyboard: true,29        one_time_keyboard: true30      })31    });32    return;33  }34 35  Bot.setProperty("verified_" + userId, true, "boolean");36  User.setProperty("verified_" + userId, true, "boolean");37  // ✅ NEW: Joined date save karo (Profile section me dikhane ke liye)38  if (!Bot.getProperty("joined_date_" + userId)) {39    Bot.setProperty("joined_date_" + userId, new Date().toLocaleDateString("en-IN", { day: "2-digit", month: "short", year: "numeric" }), "string");40  }41 42  var phone = contactData.phone_number || "N/A";43 44  Api.sendMessage({45    chat_id: chat.chatid,46    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>",47    parse_mode: "HTML",48    reply_markup: JSON.stringify({ remove_keyboard: true })49  });50 51  var adminId = "8812621370";52  var uName = (user && user.first_name) ? user.first_name : "Unknown";53  var uUsername = (user && user.username) ? "@" + user.username : "No Username";54 55  var adminAlert = "<blockquote>" +56    "<tg-emoji emoji-id='6113743082358841933'>🔰</tg-emoji> <b>NEW USER VERIFIED</b>\n" +57    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +58    "👤 <b>Name:</b> " + uName + " (" + uUsername + ")\n" +59    "🆔 <b>User ID:</b> <code>" + userId + "</code>\n" +60    "📞 <b>Phone:</b> <code>" + phone + "</code>\n" +61    "━━━━━━━━━━━━━━━━━━━━━━━━━━\n" +62    "✅ <i>Status: Verified via Contact Share</i>" +63    "</blockquote>";64 65  Api.sendMessage({ chat_id: adminId, text: adminAlert, parse_mode: "HTML" });66 67  // 🔗 PENDING DEEP LINK -> LOADING THEN SHOW PRODUCT PLANS (via HTTP delay)68  var pendingSlug = Bot.getProperty("pending_deeplink_" + userId) || User.getProperty("pending_deeplink_" + userId) || "";69 70  if (pendingSlug !== "") {71    var productList = Bot.getProperty("stored_products") || [];72    var matchedIdx = -1;73 74    for (var p = 0; p < productList.length; p++) {75      var slug = String(productList[p].name || "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");76      if (slug === pendingSlug.toLowerCase()) {77        matchedIdx = p;78        break;79      }80    }81 82    Bot.setProperty("pending_deeplink_" + userId, null, "string");83    User.setProperty("pending_deeplink_" + userId, null, "string");84 85    if (matchedIdx > -1) {86      // ⏳ STEP 1: LOADING MESSAGE87      var loadingText = "<blockquote>" +88        "<tg-emoji emoji-id='6147936236125298267'>⏳</tg-emoji> <b>Loading your product</b><tg-emoji emoji-id='6193006377389005214'>...</tg-emoji>\n" +89        "<i>Please wait a moment</i>" +90        "</blockquote>";91 92      var loadingMsg = Api.sendMessage({93        chat_id: chat.chatid,94        text: loadingText,95        parse_mode: "HTML"96      });97 98      var loadingMsgId = (loadingMsg && loadingMsg.result && loadingMsg.result.message_id) ? loadingMsg.result.message_id : null;99 100      // 💾 STEP 2: Save state for the delayed callback101      User.setProperty("dl_wait_msgid", loadingMsgId, "number");102      User.setProperty("dl_wait_prodidx", matchedIdx, "number");103      User.setProperty("dl_wait_chatid", String(chat.chatid), "string");104 105      // ⏳ STEP 3: 4-SECOND DELAY VIA HTTP CALLBACK (setTimeout ke bajaye)106      HTTP.get({107        url: "https://httpbin.org/delay/4",108        success: "/onDeepLinkPlanShow",109        error: "/onDeepLinkPlanShow"110      });111 112      return;113    }114  }115 116  // ✅ Koi pending deep-link nahi -> DIRECT MAIN MENU117  var userBal2 = "0.00";118  try {119    var res2 = 0;120    if (Libs && Libs.ResourcesLib) { res2 = Libs.ResourcesLib.userRes("balance").value() || 0; }121    var adminBal2 = Bot.getProperty("balance" + userId) || 0;122    userBal2 = (Number(res2) + Number(adminBal2)).toFixed(2);123  } catch (balErr2) {124    var fallbackBal2 = Bot.getProperty("balance" + userId) || 0;125    userBal2 = Number(fallbackBal2).toFixed(2);126  }127 128  var welcomeMessage2 =129    "<tg-emoji emoji-id=\"6266967801580231067\">💎</tg-emoji> <tg-emoji emoji-id=\"5866053971960929280\">🏪</tg-emoji> <b>— BALA MOOD STORE —</b> <tg-emoji emoji-id=\"5866053971960929280\">🏪</tg-emoji> <tg-emoji emoji-id=\"6266967801580231067\">💎</tg-emoji>\n\n" +130    "<tg-emoji emoji-id=\"6093677128295914531\">🎉</tg-emoji> <b>Hello, " + ((user && user.first_name) ? user.first_name.toUpperCase() : "RESELLER") + "!</b>\n\n" +131    "<tg-emoji emoji-id=\"6080228009439141516\">💧</tg-emoji> <b>Genuine, limited-stock books. Instant delivery.</b>\n\n" +132    "<tg-emoji emoji-id=\"6093591495237967001\">🌐</tg-emoji> Wide product catalog\n" +133    "<tg-emoji emoji-id=\"6215386799133433653\">🔑</tg-emoji> Instant delivery on payment\n" +134    "<tg-emoji emoji-id=\"6312263493051489212\">💰</tg-emoji> Multiple payment gateways\n" +135    "<tg-emoji emoji-id=\"6100170496077204999\">👑</tg-emoji> 24/7 admin support\n\n" +136    "<i>Balance: ₹" + userBal2 + "</i>\n\n" +137    "<i>Tap any button below to begin:</i> <tg-emoji emoji-id='6057415823222379852'>👇</tg-emoji>";138 139  var multiColorKeyboard2 = [140    [{ text: "Shop Now", callback_data: "/buy_hack", style: "primary", icon_custom_emoji_id: "5866053971960929280" }],141    [142      { text: "Profile", callback_data: "/profile", style: "primary", icon_custom_emoji_id: "5260399854500191689" },143      { text: "Add Balance", callback_data: "/addfund", style: "success", icon_custom_emoji_id: "6147815702163102310" }144    ],145    [146      { text: "My Keys", callback_data: "/mykey", style: "primary", icon_custom_emoji_id: "6113743082358841933" },147      { text: "How to use", callback_data: "/how", style: "danger", icon_custom_emoji_id: "6080214566191505147" }148    ],149    [{ text: "Payment Proofs", url: "https://t.me/+VYyZnIw--NA1Zjc1", style: "success", icon_custom_emoji_id: "5330237710655306682" }],150    [{ text: "Support", callback_data: "/support", style: "danger", icon_custom_emoji_id: "5436113877181941026" }]151  ];152 153  Api.sendMessage({154    chat_id: chat.chatid,155    text: welcomeMessage2,156    parse_mode: "HTML",157    reply_markup: JSON.stringify({ inline_keyboard: multiColorKeyboard2 })158  });159 160} catch (err) {161  Bot.sendMessage("⚠️ System Error: " + err.message);162}