455 commands2 envUpdated 7h agoCreated Aug 26, 2026
commands/petpl.js
javascript · 51 lines
1/**#command2name: petpl3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: petpl14answer: 15keyboard: 16parse_mode: 17aliases: 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}30if (!uid) return;31 32var ZU = 1000000;33var raw = String((await db.global.get("pet_" + uid)) || "");34if (!raw) { Bot.sendMessage("پت نداری."); return; }35var p = {};36try { p = JSON.parse(raw); } catch (eP) { p = {}; }37if ((parseInt(p.hun) || 0) < 20) { Bot.sendMessage("پت گرسنه است. اول غذا."); return; }38var w = parseInt(await db.global.get("wal_" + uid) || 0) || 0;39if (w < 2 * ZU) { Bot.sendMessage("۲ ZC."); return; }40await db.global.set("wal_" + uid, w - 2 * ZU);41p.hun = (parseInt(p.hun) || 0) - 8;42if (p.hun < 0) p.hun = 0;43p.xp = (parseInt(p.xp) || 0) + 8;44p.last = Date.now();45await db.global.set("pet_" + uid, JSON.stringify(p));46var xp = (parseInt(await db.global.get("xp_" + uid) || 0) || 0) + 4;47await db.global.set("xp_" + uid, xp);48Bot.sendMessage("🎾 بازی کرد. XP پت +۸");49try { Bot.runCommand("pet"); } catch (e1) {}50 51} catch (e) { Bot.sendMessage("خطا petpl"); }