telebothost/RewardCraftBotPublic · Community Store Listing
Reward Craft
6 commands0 envUpdated 6mo agoCreated Dec 27, 2025
commands/_.js
javascript · 95 lines · click line # to share
1/**#command2name: *3answer: 4keyboard: 5parse_mode: 6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/* ================================13 GLOBAL: REPLY BASED TRANSFER14=================================*/15 16if (!request.chat || request.chat.type === "private") return;17 18let GID = request.chat.id;19if (!Bot.get("group_enabled_" + GID)) return; // ❌ group not activated20 21if (!request.reply_to_message) return;22let sender = request.from;23let receiver = request.reply_to_message.from;24 25if (sender.id === receiver.id) return;26if (receiver.is_bot) return;27 28let txt = (request.text || "").trim();29if (!/^-?\d+$/.test(txt)) return;30 31let amount = parseInt(txt);32if (amount === 0) return;33 34// admin check35let adminCheck = await Api.getChatMember({ chat_id: GID, user_id: sender.id });36let isAdmin = ["creator","administrator"].includes(adminCheck?.result?.status);37 38// normal user can't send -39if (!isAdmin && amount < 0) return;40 41// per-group balance42let sKey = `balance_${sender.id}_${GID}`;43let rKey = `balance_${receiver.id}_${GID}`;44 45let sBal = Number(Bot.get(sKey) || 0);46let rBal = Number(Bot.get(rKey) || 0);47 48// insufficient49if (!isAdmin && sBal < amount) {50 return Api.sendMessage({51 chat_id: GID,52 reply_to_message_id: request.message_id,53 text: `❌ Not enough balance.\n💰 Balance: <b>${sBal} 💎</b>`,54 parse_mode: "HTML"55 });56}57 58// update59if (!isAdmin) Bot.set(sKey, sBal - amount);60Bot.set(rKey, rBal + amount);61 62// names63let from = isAdmin ? "admin" : (sender.username ? "@"+sender.username : sender.first_name);64let to = receiver.username ? "@"+receiver.username : receiver.first_name;65 66// render message67Api.sendMessage({68 chat_id: GID,69 reply_to_message_id: request.reply_to_message.message_id,70 parse_mode: "HTML",71 text: `<b>${amount > 0 ? "+" : ""}${amount} 💎 transferred</b>\n${from} → ${to}`72});73 74/* ----- SAVE HISTORY GLOBAL ----- */75function saveHistory(uid, rec){76 let k = `history_${uid}`;77 let h = Bot.get(k);78 try{ h = h ? JSON.parse(h) : []; }catch(e){ h = [] }79 80 h.unshift(rec);81 if(h.length > 5) h = h.slice(0,5);82 83 Bot.set(k, JSON.stringify(h));84}85 86let rec = {87 t: Date.now(),88 from: from,89 to: to,90 amount: amount,91 group: GID92};93 94saveHistory(sender.id, rec);95saveHistory(receiver.id, rec);