455 commands2 envUpdated 6h agoCreated Aug 26, 2026
commands/vfago.js
javascript · 83 lines
1/**#command2name: vfago3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: vfago14answer: 15keyboard: 16parse_mode: markdown17aliases: 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;30await db.global.set("await_vfa_" + uid, "");31 32var hasVoice = false;33try {34 if (typeof message === "object" && message && (message.voice || message.audio)) hasVoice = true;35 if (!hasVoice && typeof update !== "undefined" && update && update.message && (update.message.voice || update.message.audio)) hasVoice = true;36} catch (eV) {}37if (hasVoice) {38 Bot.sendMessage("این دکمه متن را به ویس تبدیل میکند.\nویس نفرست. متن فارسی تایپ کن.");39 return;40}41 42var text = "";43if (typeof message !== "undefined" && message) {44 if (typeof message === "object") text = String(message.text || message.caption || "");45 else text = String(message);46}47text = String(text || "").trim();48if (!text || text === "لغو" || text === "cancel" || text === "🔴 لغو") {49 Bot.sendMessage("لغو شد");50 return;51}52if (text.length > 160) { Bot.sendMessage("کوتاهتر بفرست (تا ۱۶۰ حرف)"); return; }53var hasFa = false;54var i = 0;55for (i = 0; i < text.length; i++) {56 var c = text.charCodeAt(i);57 if (c >= 1536 && c <= 1791) { hasFa = true; break; }58}59if (!hasFa) { Bot.sendMessage("فقط متن فارسی."); return; }60var q = encodeURIComponent(text);61var url1 = "https://translate.google.com/translate_tts?ie=UTF-8&tl=fa&client=tw-ob&q=" + q;62var sent = false;63try {64 await Api.sendAudio({ audio: url1, title: "ویس فارسی", performer: "Zorenix" });65 sent = true;66} catch (e1) { sent = false; }67if (!sent) {68 try {69 await Api.sendVoice({ voice: url1 });70 sent = true;71 } catch (e2) { sent = false; }72}73if (!sent) {74 var url2 = "https://translate.googleapis.com/translate_tts?ie=UTF-8&client=gtx&tl=fa&q=" + q;75 try {76 await Api.sendAudio({ audio: url2, title: "ویس فارسی", performer: "Zorenix" });77 sent = true;78 } catch (e3) { sent = false; }79}80if (!sent) {81 Bot.sendMessage("تلگرام فایل ویس را نگرفت. متنت:\n" + text);82}83} catch (e) { Bot.sendMessage("خطا vfago"); }