ayushyadav7970824760/goldensellingstore_botPublic · Bot Template

AIThis Telegram store bot lets customers browse digital products and plans, apply coupons, add funds via UPI, and receive purchased keys. It includes a full admin panel for managing products, reordering items, setting reseller prices, viewing and removing key stock, configuring UPI payment details and update links, and checking user balances. Co-admins and resellers are supported, and support tickets are forwarded to the admin.

Commercedigital_storeadmin_panelupi_paymentsresellercouponskey_stock
ProfileTelegram
146 commands0 envUpdated 2d agoCreated Sep 5, 2026
Back to folder

commands/_refer.js

javascript · 82 lines

Raw
1/**#command2name: /refer3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🎁 REFER & EARN — user-facing screen14// Shows the user's own referral link + how much they've earned so far.15// Bonus crediting logic lives in _start.js (capture), _onCheck.js16// (topup bonus) and _confirm_buyitem.js / _onWebKeyReceive.js (buy bonus).17// ✅ Redesigned to match the premium "Referral Program" reference layout —18// tree-style stats block + Status badge, reusing existing premium emoji IDs.19// =========================================================20 21try {22  var userId = String(user.telegramid);23  var botUsername = Bot.getProperty("bot_username") || "goldensellingstore_bot";24 25  var referralLink = "https://t.me/" + botUsername + "?start=ref" + userId;26 27  var referralCount = (Bot.getProperty("referrals_of_" + userId) || []).length;28  var totalEarned = Number(Bot.getProperty("refer_earnings_" + userId) || 0);29 30  var topupBonus = Number(Bot.getProperty("refer_earn_topup_amount"));31  if (isNaN(topupBonus)) topupBonus = 2;32  var buyBonus = Number(Bot.getProperty("refer_earn_buy_amount"));33  if (isNaN(buyBonus)) buyBonus = 2;34 35  // ✅ Plain Unicode emoji — guessed custom IDs render wrong/mismatched icons36  var e_gift    = "🎁";37  var e_money   = "<tg-emoji emoji-id='6267068789146260253'>💰</tg-emoji>";38  var e_stats   = "<tg-emoji emoji-id='6039605143601680423'>📊</tg-emoji>";39  var e_ref     = "🎯";40  var e_earned  = "<tg-emoji emoji-id='6267068789146260253'>💵</tg-emoji>";41  var e_link    = "<tg-emoji emoji-id='6091571559233755994'>🔗</tg-emoji>";42 43  var referText =44    "<blockquote>" + e_gift + " <b>Referral Program</b></blockquote>\n\n" +45    "🟢 <b>Status:</b> <code>Active</code>\n" +46    e_money + " <b>Earn ₹" + topupBonus.toFixed(2) + " + ₹" + buyBonus.toFixed(2) + "</b> commission on every friend you refer!\n\n" +47    "━━━━━━━━━━━━━━━━━━━━━\n\n" +48    e_stats + " <b>Your Stats:</b>\n" +49    "├ " + e_ref + " <b>Total Referrals:</b> " + referralCount + "\n" +50    "└ " + e_earned + " <b>Total Earned:</b> ₹" + totalEarned.toFixed(2) + "\n\n" +51    "━━━━━━━━━━━━━━━━━━━━━\n\n" +52    e_link + " <b>Your Invite Link:</b>\n<code>" + referralLink + "</code>\n\n" +53    "<i>Share your link to grow your earnings!</i>";54 55  var referButtons = [56    [{ text: "𝑺𝒉𝒂𝒓𝒆 𝑳𝒊𝒏𝒌", url: "https://t.me/share/url?url=" + encodeURIComponent(referralLink) + "&text=" + encodeURIComponent("Join karo aur turant discount pao!"), style: "success" }],57    [{ text: "𝑩𝒂𝒄𝒌", callback_data: "/back", style: "danger" }]58  ];59 60  if (request && request.message && request.message.message_id) {61    Api.editMessageText({62      chat_id: String(chat.chatid),63      message_id: Number(request.message.message_id),64      text: referText,65      parse_mode: "HTML",66      reply_markup: JSON.stringify({ inline_keyboard: referButtons })67    });68  } else {69    Api.sendMessage({70      chat_id: String(chat.chatid),71      text: referText,72      parse_mode: "HTML",73      reply_markup: JSON.stringify({ inline_keyboard: referButtons })74    });75  }76 77  var qid = request ? (request.id || (request.callback_query && request.callback_query.id)) : null;78  if (qid) { try { Api.answerCallbackQuery({ callback_query_id: String(qid) }); } catch (e) {} }79 80} catch (err) {81  Bot.sendMessage("⚠️ <b>Refer & Earn Error:</b> <code>" + err.message + "</code>", { parse_mode: "HTML" });82}