| module.exports.config = { |
| name: "ai", |
| 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, messageID } = event; |
| const followUpApiUrl = `https://ccprojectapis.ddns.net/api/gpt4?ask=${encodeURIComponent(handleReply.message)}&id=${senderID}`; |
|
|
| api.setMessageReaction("โฑ๏ธ", messageID, () => {}, true); |
|
|
| try { |
| const response = await axios.get(followUpApiUrl); |
| const followUpResult = convertToBold(response.data); |
| api.setMessageReaction("โ
", messageID, () => {}, true); |
| api.sendMessage(followUpResult, threadID, 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://ccprojectapis.ddns.net/api/gpt4?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://letmeknowbruhhthisthestoragebot.onrender.com/${timestamp}.png`; |
| const visionResponse = await axios.get(visionApiUrl); |
| |
| if (visionResponse.data && visionResponse.data) { |
| const visionText = convertToBold(visionResponse.data); |
| api.editMessage(`๐๐ฒ๐บ๐ถ๐ป๐ถ ๐ฉ๐ถ๐๐ถ๐ผ๐ป ๐ฃ๐ฟ๐ผ ๐๐บ๐ฎ๐ด๐ฒ ๐ฅ๐ฒ๐ฐ๐ผ๐ด๐ป๐ถ๐๐ถ๐ผ๐ป\nโโโโโโโโโโโโโโโโโโ\n${visionText}\nโโโโโโโโโโโโโโโโโโ\n`, lad.messageID); |
| } else { |
| api.sendMessage("๐ค Failed to recognize the image.", threadID); |
| } |
| } catch (error) { |
| api.sendMessage(`โ Error processing image: ${error.message}`, 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}. Try using ${global.config.PREFIX}ai2`, lad.messageID); |
| } |
| }; |