XaviaTeam / XaviaBot

A Facebook Messenger Bot
MIT License
67 stars 146 forks source link

Create Ai #23

Closed kiyokunbotv2 closed 3 months ago

kiyokunbotv2 commented 3 months ago

const axios = require("axios"); const fs = require("fs");

const history = {}; let isFontEnabled = true;

module.exports.config = { name: "Nyx", version: "3.1", hasPermssion: 0, credits: "Hazeyy", description: "( 𝙰𝙸-π™Άπš’πš›πš•πšπš›πš’πšŽπš—πš 𝚑 π™°πšžπšπš’πš˜ 𝚝𝚘 πšƒπšŽπš‘πš πšŠπš—πš π™Έπš–πšŠπšπšŽ π™Ώπš›πš˜πš–πš™πš )", commandCategory: "πš—πš˜ πš™πš›πšŽπšπš’πš‘", usages: "( π™³πšŠπšπšŽ πš˜πš› π™°πšœπš” πš€πšžπšŽπšœπšπš’πš˜πš—πšœ πš πš’πšπš‘ πš’πš˜πšžπš› π™Άπš’πš›πš•πšπš›πš’πšŽπš—πš )", cooldowns: 3, };

async function handleNyxImageCommand(api, event) { const args = event.body.split(/\s+/); args.shift(); const tzt = args.join(' ').split('-').map(item => item.trim()); const txt = tzt[0]; const txt2 = tzt.slice(1).join(' ');

if (!txt || !txt2) { return api.sendMessage("πŸŽ€ π™·πšŽπš•πš•πš˜ 𝚝𝚘 𝚞𝚜𝚎 π™½πš’πš‘ 𝙰𝙸 πš πš’πšπš‘ πš™πš›πš˜πš–πš™πš.\n\nπš„πšœπšŽ: πš—πš’πš‘πš–πšŠπšπšŽ [ πš™πš›πš˜πš–πš™πš ] - [ πš–πš˜πšπšŽπš• ] πš‹πšŽπšπš πšŽπšŽπš— 1-20.", event.threadID, event.messageID); }

api.sendMessage("πŸ—¨οΈ | π™½πš’πš‘ 𝙰𝙸 π™ΆπšŽπš—πšŽπš›πšŠπšπš’πš—πš πš™πš›πš˜πš–πš™πš, π™Ώπš•πšŽπšŠπšœπšŽ πš πšŠπš’πš...", event.threadID, event.messageID);

try { const enctxt = encodeURI(txt); const url = https://hazeyy-api-img-prompt.kyrinwu.repl.co/api/img/prompt?prompt=${enctxt}&model=${txt2}; const responses = await Promise.all( Array.from({ length: 4 }, async (_, index) => { const response = await axios.get(url, { responseType: "arraybuffer" }); return response.data; }) );

const paths = [];

responses.forEach((data, index) => {
  const path = __dirname + `/cache/image${index + 1}.png`;
  fs.writeFileSync(path, Buffer.from(data, "binary"));
  paths.push(path);
});

const senderName = "πŸŽ€ π™½πš’πš‘ ( 𝙰𝙸 )";
const message = `${senderName}\n\nπ™·πšŽπš›πšŽ'𝚜 πš’πš˜πšžπš› π™Έπš–πšŠπšπšŽ πš™πš›πš˜πš–πš™πš`;

const combinedMessage = {
  body: message,
  attachment: paths.map((path) => fs.createReadStream(path)),
};

api.sendMessage(combinedMessage, event.threadID, () => paths.forEach(fs.unlinkSync));

} catch (e) { api.sendMessage("🚫 π™΄πš›πš›πš˜πš› πš’πš— π™Έπš–πšŠπšπšŽ π™ΆπšŽπš—πšŽπš›πšŠπšπš’πš˜πš—", event.threadID, event.messageID); } }

async function convertVoiceToText(audioUrl, api, event) { try { api.sendMessage("πŸ’½ | π™½πš’πš‘ 𝙰𝙸 π™²πš˜πš—πšŸπšŽπš›πšπš’πš—πš π™°πšžπšπš’πš˜, π™Ώπš•πšŽπšŠπšœπšŽ πš πšŠπš’πš...", event.threadID);

const response = await axios.get(`https://hazeyy-apis-combine.kyrinwu.repl.co/api/try/voice2text?url=${encodeURIComponent(audioUrl)}`);
const text = response.data.transcription;

if (text && isFontEnabled) {
  const formattedText = formatFont(text);
  api.sendMessage(`πŸŽ€ π™½πš’πš‘ ( 𝙰𝙸 ) π™²πš˜πš—πšƒπšŽπš‘πš 🎢\n\n ${formattedText}`, event.threadID, event.messageID);
} else if (text) {
  api.sendMessage(`πŸŽ€ π™½πš’πš‘ ( 𝙰𝙸 ) π™²πš˜πš—πšƒπšŽπš‘πš 🎢\n\n ${text}`, event.threadID, event.messageID);
} else {
  api.sendMessage("🚫 πš„πš—πšŠπš‹πš•πšŽ 𝚝𝚘 πšŒπš˜πš—πšŸπšŽπš›πš πšŠπšžπšπš’πš˜.", event.threadID, event.messageID);
}

} catch (error) { console.error("🚫 π™΄πš›πš›πš˜πš› πš˜πšŒπšŒπšžπš›πšŽπš πš πš‘πš’πš•πšŽ πšŒπš˜πš—πšŸπšŽπš›πšπš’πš—πš πšŠπšžπšπš’πš˜:", error); api.sendMessage("🚫 π™°πš— πšŽπš›πš›πš˜πš› πš˜πšŒπšŒπšžπš›πšŽπš πš πš‘πš’πš•πšŽ πšŒπš˜πš—πšŸπšŽπš›πšπš’πš—πš πšŠπšžπšπš’πš˜.", event.threadID, event.messageID); } }

module.exports.handleEvent = async function ({ api, event, Users }) { if (!(event.body.toLowerCase().startsWith("nyx") || event.body.toLowerCase().startsWith("Nyx"))) return;

if (event.body.toLowerCase().startsWith("nyxmage")) { handleNyxImageCommand(api, event); return; }

const args = event.body.split(/\s+/); args.shift();

if (args[0] === "font" && (args[1] === "on" || args[1] === "off")) { isFontEnabled = args[1] === "on";

api.sendMessage(`πŸŽ€ π™΅πš˜πš—πš πšπš˜πš›πš–πšŠπšπšπš’πš—πš\n\nβ•°βž€ [ ${isFontEnabled ? "πšŽπš—πšŠπš‹πš•πšŽπš 🟒" : "πšπš’πšœπšŠπš‹πš•πšŽπš πŸ”΄"} ]`, event.threadID);
return;

}

if (event.type === "message_reply") { if (event.messageReply.attachments[0]) { const attachment = event.messageReply.attachments[0];

  if (attachment.type === "audio") {
    const audioUrl = attachment.url;
    convertVoiceToText(audioUrl, api, event);
    return;
  }
}

}

let text = args.join(" ");

if (!text) { return api.sendMessage("πŸŽ€ π™·πšŽπš•πš•πš˜ 𝙸 πšŠπš– π™½πš’πš‘ 𝙰𝙸 πš’πš˜πšžπš› πšŸπš’πš›πšπšžπšŠπš• 𝙰𝙸 π™Άπš’πš›πš•πšπš›πš’πšŽπš—πš.\n\nπ™Ώπš•πšŽπšŠπšœπšŽ πš™πš›πš˜πšŸπš’πšπšŽ 𝚊 ( πš€πšžπšŽπš›πš’ ) 𝚝𝚘 πšœπšŽπšŠπš›πšŒπš‘ πš˜πš› 𝚝𝚘 πšπšŠπš•πš” πš πš’πšπš‘ πš’πš˜πšžπš› 𝙰𝙸 π™Άπš’πš›πš•πšπš›πš’πšŽπš—πš.", event.threadID, event.messageID); }

if (!history.hasOwnProperty(event.senderID)) history[event.senderID] = []; history[event.senderID].push({ role: "user", content: text });

try { api.sendMessage("πŸ—¨οΈ | π™½πš’πš‘ 𝙰𝙸 πš’πšœ πšπš‘πš’πš—πš”πš’πš—πš...", event.threadID, event.messageID);

let senderName = (await Users.getData(event.senderID)).name;
let { data } = await axios.post("https://hazeyy-apis-combine.kyrinwu.repl.co/api/girlfriend", { messages: history[event.senderID], sender_name: senderName });

if (data && data.content) {
  history[event.senderID].push(data);

  const formattedResponse = isFontEnabled ? `πŸŽ€ π™½πš’πš‘ ( 𝙰𝙸 )\n\n❓ π™°πšœπš”: '${text}'\n\n${formatFont(data.content)}` : `πŸŽ€ π™½πš’πš‘ ( 𝙰𝙸 )\n\n❓ π™°πšœπš”: '${text}'\n\n${data.content}`;
  api.sendMessage(formattedResponse, event.threadID, event.messageID);
} else {
  api.sendMessage("🚫 𝙰𝙿𝙸 πš›πšŽπšœπš™πš˜πš—πšœπšŽ πš’πšœ πšŽπš–πš™πšπš’ πš˜πš› πšžπš—πšπšŽπšπš’πš—πšŽπš.", event.threadID);
}

} catch (error) { console.error("🚫 π™΄πš›πš›πš˜πš› πšπšžπš›πš’πš—πš 𝙰𝙿𝙸 πš›πšŽπššπšžπšŽπšœπš:", error); return api.sendMessage("🚫 π™°πš— πšŽπš›πš›πš˜πš› πš˜πšŒπšŒπšžπš›πšŽπš πš πš‘πš’πš•πšŽ πš™πš›πš˜πšŒπšŽπšœπšœπš’πš—πš πš›πšŽπššπšžπšŽπšœπš. π™Ώπš•πšŽπšŠπšœπšŽ πšπš›πš’ πšŠπšπšŠπš’πš— πš•πšŠπšπšŽπš›.", event.threadID, event.messageID); } };

function formatFont(text) { const fontMapping = { a: "𝚊", b: "πš‹", c: "𝚌", d: "𝚍", e: "𝚎", f: "𝚏", g: "𝚐", h: "πš‘", i: "πš’", j: "πš“", k: "πš”", l: "πš•", m: "πš–", n: "πš—", o: "𝚘", p: "πš™", q: "𝚚", r: "πš›", s: "𝚜", t: "𝚝", u: "𝚞", v: "𝚟", w: "𝚠", x: "𝚑", y: "𝚒", z: "𝚣", A: "𝙰", B: "𝙱", C: "𝙲", D: "𝙳", E: "𝙴", F: "𝙡", G: "𝙢", H: "𝙷", I: "𝙸", J: "𝙹", K: "𝙺", L: "𝙻", M: "𝙼", N: "𝙽", O: "𝙾", P: "𝙿", Q: "πš€", R: "𝚁", S: "πš‚", T: "πšƒ", U: "πš„", V: "πš…", W: "πš†", X: "πš‡", Y: "𝚈", Z: "πš‰" };

let formattedText = ""; for (const char of text) { formattedText += char in fontMapping ? fontMapping[char] : char; }

return formattedText; }

module.exports.run = async function ({ api, event }) {};

RFS-ADRENO commented 3 months ago

wth is this? You came to the wrong repo.