module.exports.config = { name: "ai2", version: "1.0.0", permission: 0, credits: "Jonell Magallanes", usePrefix: false, premium: false, description: "Educational AI chatbot powered by GPT-4 and image recognition.", commandCategory: "AI", usages: "ai [question]", cooldowns: 6, }; const axios = require('axios'); const fs = require('fs'); const https = require('https'); 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': 'š˜‡' }; function convertToBold(text) { return text.replace(/\*(.*?)\*/g, (match, p1) => [...p1].map(char => fontMapping[char] || char).join('')) .replace(/### (.*?)(\n|$)/g, (match, p1) => `${[...p1].map(char => fontMapping[char] || char).join('')}`); } module.exports.handleReply = async ({ handleReply, event, api }) => { const { threadID, senderID } = event; const followUpApiUrl = `https://jonellpogi.serv00.net/aria.php?ask=${encodeURIComponent(handleReply.message)}&id=${senderID}`; api.setMessageReaction("ā±ļø", event.messageID, () => {}, true); try { const response = await axios.get(followUpApiUrl); const followUpResult = convertToBold(response.data); api.setMessageReaction("āœ…", event.messageID, () => {}, true); api.sendMessage(followUpResult, threadID, event.messageID); } catch (error) { api.sendMessage(`Error: ${error.message}`, threadID); } }; module.exports.run = async ({ event, api, args }) => { const { messageID, threadID, senderID } = event; if (!args.length) { return api.sendMessage("Please provide your question.\n\nExample: ai what is the solar system?", threadID, messageID); } const apiUrl = `https://jonellpogi.serv00.net/aria.php?ask=${encodeURIComponent(args.join(" "))}&id=${senderID}`; const lad = await api.sendMessage("šŸ”Ž Searching for an answer. Please wait...", threadID, messageID); try { if (event.type === "message_reply" && event.messageReply.attachments && event.messageReply.attachments[0].type === "photo") { const imageURL = event.messageReply.attachments[0].url; const timestamp = Date.now(); const imagePath = `./public/${timestamp}.png`; const file = fs.createWriteStream(imagePath); https.get(imageURL, (response) => { response.pipe(file); file.on("finish", async () => { try { const visionApiUrl = `https://jonellpogi.serv00.net/gemini.php?prompt=${encodeURIComponent(args.join(" "))}&url=https://bot-cc-storage-image.onrender.com/${timestamp}.png`; const visionResponse = await axios.get(visionApiUrl); const visionText = convertToBold(visionResponse.data); // āœ… Corrected field extraction if (visionText) { api.editMessage(`š—šš—²š—ŗš—¶š—»š—¶ š—©š—¶š˜€š—¶š—¼š—» š—£š—æš—¼ š—œš—ŗš—®š—“š—² š—„š—²š—°š—¼š—“š—»š—¶š˜š—¶š—¼š—»\n━━━━━━━━━━━━━━━━━━\n${visionText}\n━━━━━━━━━━━━━━━━━━\n`, lad.messageID); } else { api.sendMessage("šŸ¤– Failed to recognize the image.", threadID); } } catch { api.sendMessage("Error processing image.", threadID); } }); }); } else { const response = await axios.get(apiUrl); const result = convertToBold(response.data); api.editMessage(`${result}`, lad.messageID); } global.client.handleReply.push({ name: this.config.name, messageID: lad.messageID, author: senderID, }); } catch (error) { api.editMessage(`āŒ Error: ${error.message}`, lad.messageID); } };