455 commands2 envUpdated 6h agoCreated Aug 26, 2026
commands/mybuy.js
javascript · 54 lines
1/**#command2name: mybuy3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: mybuy14answer: 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}30if (!uid) return;31var nid = parseInt(await db.global.get("shop_next_order") || 1) || 1;32var lines = [];33var found = 0;34var k = 0;35for (k = 0; k < 80; k++) {36 if (found >= 5) break;37 var idx = nid - 1 - k;38 if (idx < 1) break;39 var raw = "";40 try { raw = String((await db.global.get("shop_order_" + idx)) || ""); } catch (eR) { raw = ""; }41 if (raw) {42 var o = null;43 try { o = JSON.parse(raw); } catch (eJ) { o = null; }44 if (o && String(o.uid) === uid) {45 lines.push("#" + idx + " " + String(o.title || "") + " — " + ((parseInt(o.price) || 0) / 100) + " ZC");46 found += 1;47 }48 }49}50if (lines.length === 0) Bot.sendMessage("🧾 هنوز خریدی از فروشگاه نداری.");51else Bot.sendMessage("🧾 آخرین خریدها\n" + lines.join("\n"));52} catch (e) {53 Bot.sendMessage("خطا mybuy");54}