devbro468/Dev_x_store_botPublic · Bot Template
AIThis bot operates a digital storefront (DEV X STORE) selling subscription-based products — likely game hacks, accounts, or access keys — categorized by platform (Android Root, Non-Root, iPhone). It features a reseller program with discounted pricing, a dual-currency wallet (INR balance + Telegram Stars/XTR), and a full admin/co-admin panel for managing products, plans, per-plan pricing, stock (keys/accounts), coupons, and API endpoints. Purchases flow through a plan selection screen offering wallet payment, Stars invoices (sendInvoice with XTR currency), and coupon application. Successful Stars payments are handled via successful_payment webhook, crediting wallet or delivering keys directly. Admin tools include user listing with chunked messaging, stock viewing/deletion with inline keyboards, co-admin management, and API registry updates. The bot registers users on first interaction and
commands/_addbal.js
javascript · 97 lines
1/**#command2name: /addbal3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ✅ FIXED (v3): pehle admin_id hardcoded tha ("8875810358"), jabki baaki bot13// (start menu, /admin, ownership transfer) sab dynamic "owner_id" property use14// karte hain. Agar kabhi ownership transfer hua ya co-admin ne button dabaya,15// ye command silently "not authorized" de deta tha — isiliye "Add Bal" button16// theek se kaam nahi kar raha tha. Ab yahan bhi wahi dynamic check hai.17let admin_id = Bot.getProperty("owner_id") || "8875810358";18let requesterId = String(user.telegramid);19let isCoAdmin = Bot.getProperty("co_admin_" + requesterId);20 21if (requesterId === admin_id || isCoAdmin) {22 23 // ✅ FIXED: button dabate hi Telegram ka loading-spinner turant hata do,24 // taaki click "fast/responsive" mehsoos ho (pehle koi answerCallbackQuery25 // nahi tha, isliye button dabane par kuch second tak kuch nahi hota tha).26 if (request && request.id) {27 try {28 HTTP.post({29 url: "https://api.telegram.org/bot" + bot.token + "/answerCallbackQuery",30 body: { callback_query_id: request.id }31 });32 } catch (ackErr) {}33 }34 35 let params = (typeof message !== "undefined" && message) ? message.split(" ") : [];36 let data = params[1];37 38 // ✅ FIXED: pehle "Add Bal" admin-panel button dabane par ye seedha "Wrong39 // Format" error de deta tha (kyunki button koi text argument nahi bhejta),40 // aur admin ko turant type karna padta tha "/addbal id|amount" khud se.41 // Ab button dabane par ek proper prompt aata hai aur agla text message42 // auto-capture ho jaata hai (see _start.js "MODULE 5").43 if (!data || !data.includes("|")) {44 User.setProperty("addbal_step", "waiting_input", "string");45 Bot.sendMessage(46 "<tg-emoji emoji-id='5409048419211682843'>💵</tg-emoji> <b>Add Balance</b>\n\n" +47 "<i>User ID aur amount is format me reply karein:</i>\n<code>user_id|amount</code>\n\n" +48 "<i>Example:</i> <code>8875810358|100</code>",49 {parse_mode: "HTML"}50 );51 return;52 }53 54 let splitData = data.split("|");55 let targetUserId = splitData[0].trim();56 let amountToAdd = parseFloat(splitData[1].trim());57 58 if (!targetUserId || isNaN(amountToAdd) || amountToAdd <= 0) {59 Bot.sendMessage("❌ *Invalid Format! Use:* `user_id|amount`", {parse_mode: "Markdown"});60 return;61 }62 63 try {64 // Balance add karna65 let targetUserBalance = Libs.ResourcesLib.anotherUserRes("balance", targetUserId);66 targetUserBalance.add(amountToAdd);67 68 // Admin notification — turant confirm karo ki balance credit ho gaya69 Bot.sendMessage("✅ Success! Added " + amountToAdd + " to user " + targetUserId, {parse_mode: "HTML"});70 71 // All 4 Premium Emojis in Quote Style72 let notificationText =73 "<blockquote>" +74 "<tg-emoji emoji-id='6192822213486321961'>🗣</tg-emoji> Admin Added: " + amountToAdd + "\n" +75 "<tg-emoji emoji-id='6266967801580231067'>💎</tg-emoji> Balance Credited!\n" +76 "<tg-emoji emoji-id='6267068789146260253'>💰</tg-emoji> Wallet Updated\n" +77 "<tg-emoji emoji-id='5866053971960929280'>🛒</tg-emoji> /start TO SHOP NOW" +78 "</blockquote>";79 80 // ✅ FIXED: raw HTTP.post ki jagah bot ka built-in Api.sendMessage use kiya —81 // yahi wrapper baaki poore bot me reliably use ho raha hai, isliye user-side82 // notification bhi consistently aur fast deliver hota hai.83 try {84 Api.sendMessage({85 chat_id: targetUserId,86 text: notificationText,87 parse_mode: "HTML"88 });89 } catch (notifyErr) {}90 91 } catch (err) {92 Bot.sendMessage("⚠️ *Error:* " + err.message, {parse_mode: "Markdown"});93 }94 95} else {96 Bot.sendMessage("❌ You are not authorized to use this command.");97}