455 commands2 envUpdated 7h agoCreated Aug 26, 2026
commands/onTarotSuccess.js
javascript · 105 lines
1/**#command2name: onTarotSuccess3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: onTarotSuccess14answer: 15keyboard: 16parse_mode: markdown17aliases: 18allow_only_group: false19need_reply: false20is_web: 021#command**/22 23// پاسخ ویژهٔ فال تاروت (کارتهای کشیدهشده را هم نشان میدهد)24try {25 26var raw = null;27if (typeof content !== "undefined" && content !== null && content !== "") {28 raw = content;29} else if (typeof http_response !== "undefined" && http_response) {30 raw = (http_response.data !== undefined) ? http_response.data : http_response;31}32 33var data = raw;34if (typeof raw === "string") {35 var t0 = String(raw);36 if (t0.length > 0 && (t0.charAt(0) === "{" || t0.charAt(0) === "[")) {37 try { data = JSON.parse(t0); } catch (eP) { data = raw; }38 }39}40 41var answer = "";42try {43 if (data && data.choices && data.choices[0] && data.choices[0].message) {44 answer = String(data.choices[0].message.content || data.choices[0].message.reasoning || "");45 } else if (data && data.choices && data.choices[0] && data.choices[0].text) {46 answer = String(data.choices[0].text);47 }48} catch (e1) {}49if (!answer && typeof raw === "string") answer = String(raw);50if (!answer) answer = "جوابی نیامد. یک بار دیگر /tarot را بزن.";51 52// حذف برچسبهای thinking که بعضی مدلها قبل جواب میفرستند53var LT = String.fromCharCode(60), GT = String.fromCharCode(62);54answer = String(answer).split(LT + "/think" + GT).join("");55answer = answer.split(LT + "think" + GT).join("");56answer = answer.trim();57 58var cid = "";59try {60 if (typeof chat !== "undefined" && chat) {61 if (chat.chatid) cid = String(chat.chatid);62 else if (chat.id) cid = String(chat.id);63 }64} catch (e2) {}65 66var cards = "";67try { cards = String((await db.global.get("last_tarot_cards_" + cid)) || ""); } catch (e3) {}68var intent = "";69try { intent = String((await db.global.get("last_tarot_intent_" + cid)) || ""); } catch (e4) {}70 71var head = "🔮 فال تاروت زورنیکس AI\n";72if (intent) head += "🎯 نیت: " + intent + "\n";73if (cards) head += "🎴 کارتهای شما: " + cards + "\n";74head += "────────────────\n\n";75 76var full = head + answer;77 78var parts = [];79for (var i = 0; i < full.length; i += 3500) parts.push(full.slice(i, i + 3500));80if (parts.length === 0) parts = [full];81 82for (var p = 0; p < parts.length; p++) {83 var isLast = (p === parts.length - 1);84 if (isLast) {85 try {86 Api.sendMessage({87 text: parts[p],88 reply_markup: {89 inline_keyboard: [90 [{ text: "🔮 فال تازه", callback_data: "/tarot" }],91 [{ text: "📢 کانال ما", url: "https://t.me/ZorenixStudio" }]92 ]93 }94 });95 } catch (e5) {96 Bot.sendMessage(parts[p]);97 }98 } else {99 Bot.sendMessage(parts[p]);100 }101}102 103} catch (err) {104 try { Bot.sendMessage("⚠️ تاروت: مشکلی در دریافت فال رخ داد. دوباره /tarot را بزن."); } catch (e9) {}105}