455 commands2 envUpdated 6h agoCreated Aug 26, 2026
commands/trnin.js
javascript · 64 lines
1/**#command2name: trnin3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: trnin14answer: 15keyboard: 16parse_mode: 17aliases: 18allow_only_group: false19need_reply: false20is_web: 021#command**/22 23try {24var uid = "";25if (typeof user !== "undefined" && user) {26 if (user.telegramid) uid = String(user.telegramid);27 else if (user.id) uid = String(user.id);28}29if (!uid) return;30var text = "";31if (typeof params !== "undefined" && params) text = String(params).trim();32if (!text && typeof message !== "undefined" && message) {33 if (typeof message === "object") text = String(message.text || "");34 else text = String(message);35}36text = String(text || "").trim();37if (text === "لغو" || text === "🔴 لغو") {38 await db.global.set("await_trn_" + uid, "");39 Bot.sendMessage("لغو شد");40 return;41}42if (!text) { Bot.sendMessage("نیکنیم را بفرست."); return; }43await db.global.set("await_trn_" + uid, "");44var mx = parseInt(await db.global.get("trn_max") || 16) || 16;45var list = [];46try { list = JSON.parse(String((await db.global.get("trn_list")) || "[]")); } catch (eL) { list = []; }47if (!list || typeof list.length !== "number") list = [];48var wait = [];49try { wait = JSON.parse(String((await db.global.get("trn_wait")) || "[]")); } catch (eW) { wait = []; }50if (!wait || typeof wait.length !== "number") wait = [];51var i = 0;52for (i = 0; i < list.length; i++) {53 if (list[i] && String(list[i].uid) === uid) { Bot.sendMessage("قبلاً ثبتنام کردی."); return; }54}55if (list.length < mx) {56 list.push({ uid: uid, ign: text.slice(0, 24) });57 await db.global.set("trn_list", JSON.stringify(list));58 Bot.sendMessage("✅ داخل ظرفیت اصلی.\n" + list.length + "/" + mx);59} else {60 wait.push(uid);61 await db.global.set("trn_wait", JSON.stringify(wait));62 Bot.sendMessage("ظرفیت پر است. رفتی لیست انتظار. #" + wait.length);63}64} catch (e) { Bot.sendMessage("خطا trnin"); }