455 commands2 envUpdated 7h agoCreated Aug 26, 2026
commands/sren.js
javascript · 63 lines
1/**#command2name: sren3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: sren14answer: 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 sp = raw.indexOf(" ");36if (sp < 1) {37 Bot.sendMessage("اسم محصول:\n/sren شماره عنوان جدید\nمثال: /sren 2 پلن نرمال یکماهه");38 return;39}40var num = parseInt(raw.slice(0, sp).replace(/[^0-9]/g, "")) || 0;41var title = raw.slice(sp + 1).trim().slice(0, 80);42if (num < 1 || !title) { Bot.sendMessage("شماره و عنوان لازم است."); return; }43var products = [];44try { products = JSON.parse(String((await db.global.get("shop_products")) || "[]")); } catch (eP) { products = []; }45if (!products || typeof products.length !== "number") products = [];46var i = 0;47var hit = false;48for (i = 0; i < products.length; i++) {49 if (!products[i]) continue;50 var n = parseInt(products[i].num);51 if (!n) n = i + 1;52 if (n === num || parseInt(products[i].id) === num) {53 products[i].title = title;54 hit = true;55 Bot.sendMessage("✅ اسم محصول " + n + " شد:\n" + title);56 break;57 }58}59if (!hit) { Bot.sendMessage("شماره محصول نیست."); return; }60await db.global.set("shop_products", JSON.stringify(products));61} catch (e) {62 Bot.sendMessage("خطا sren");63}