455 commands2 envUpdated 6h agoCreated Aug 26, 2026
commands/sped.js
javascript · 64 lines
1/**#command2name: sped3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: sped14answer: 15keyboard: 16parse_mode: markdown17aliases: 18allow_only_group: false19need_reply: false20is_web: 021#command**/22 23try {24try { Api.answerCallbackQuery({}); } catch (e0) {}25var uid = "";26if (typeof user !== "undefined" && user) {27 if (user.telegramid) uid = String(user.telegramid);28 else if (user.id) uid = String(user.id);29}30var isBoss = (uid === "5861439682");31var isAdmin = isBoss || ((await db.global.get("rank_" + uid)) === "admin");32if (!isAdmin) { Bot.sendMessage("🚫 فقط ادمین"); return; }33var raw = "";34if (typeof params !== "undefined" && params) raw = String(params).trim();35var parts = raw.split(" ");36var num = parseInt(parts[0] || "0") || 0;37var zc = parseFloat(parts[1] || "0") || 0;38if (num < 1 || zc < 0.01) {39 Bot.sendMessage("قیمت به ZC:\n/sped شماره قیمت\nمثال: /sped 2 590");40 return;41}42var toman = Math.floor(zc * 100);43if (toman < 1) toman = 1;44var products = [];45try { products = JSON.parse(String((await db.global.get("shop_products")) || "[]")); } catch (eP) { products = []; }46if (!products || typeof products.length !== "number") products = [];47var i = 0;48var hit = false;49for (i = 0; i < products.length; i++) {50 if (!products[i]) continue;51 var n = parseInt(products[i].num);52 if (!n) n = i + 1;53 if (n === num || parseInt(products[i].id) === num) {54 products[i].price = toman;55 hit = true;56 Bot.sendMessage("✅ " + String(products[i].title) + "\nقیمت جدید: " + (toman / 100) + " ZC");57 break;58 }59}60if (!hit) { Bot.sendMessage("شماره محصول نیست."); return; }61await db.global.set("shop_products", JSON.stringify(products));62} catch (e) {63 Bot.sendMessage("خطا sped");64}