const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const baseApiUrl = async () => { const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"); return base.data.mahmud; }; module.exports = { config: { name: "propose2", version: "2.7", author: "MahMUD", category: "love", countDown: 10, guide: "{pn} @mention | reply" }, langs: { bn: { noTarget: "❌ অনুগ্রহ করে কাউকে মেনশন বা রিপ্লাই দিন প্রপোজ করার জন্য!", success: "𝐏𝐫𝐨𝐩𝐨𝐬𝐞 𝐌𝐚𝐭𝐜𝐡 𝐒𝐮𝐜𝐜𝐞𝐬𝐬𝐟𝐮𝐥🫶🏻\n• %1 🎀\n• %2 🎀\n💌 𝐖𝐢𝐥𝐥 𝐲𝐨𝐮 𝐦𝐚𝐫𝐫𝐲 𝐦𝐞 𝐦𝐲 𝐩𝐨𝐨𝐤𝐢𝐞 💕\n\n💙 Propose percentage: %3%", error: "× API error: %1. Contact MahMUD for help.\n•WhatsApp: 01836298139" }, en: { noTarget: "❌ Please mention or reply to someone to propose them!", success: "𝐏𝐫𝐨𝐩𝐨𝐬𝐞 𝐌𝐚𝐭𝐜𝐡 𝐒𝐮𝐜𝐜𝐞𝐬𝐬𝐟𝐮𝐥🫶🏻\n• %1 🎀\n• %2 🎀\n💌 𝐖𝐢𝐥𝐥 𝐲𝐨𝐮 𝐦𝐚𝐫𝐫𝐲 𝐦𝐞 𝐦𝐲 𝐩𝐨𝐨𝐤𝐢𝐞 💕\n\n💙 Propose percentage: %3%", error: "× API error: %1. Contact MahMUD for help.\n•WhatsApp: 01836298139" }, vi: { noTarget: "❌ Vui lòng nhắc đến hoặc trả lời ai đó để cầu hôn!", success: "Kết quả cầu hôn thành công🫶🏻\n• %1 🎀\n• %2 🎀\n💌 𝐖𝐢𝐥𝐥 𝐲𝐨𝐮 𝐦𝐚𝐫𝐫𝐲 𝐦𝐞 𝐦𝐲 𝐩𝐨𝐨𝐤𝐢𝐞 💕\n\n💙 Tỉ lệ cầu hôn: %3%", error: "× Lỗi API: %1. Liên hệ MahMUD để được trợ giúp.\n•WhatsApp: 01836298139" } }, onStart: async function ({ api, usersData, event, args, getLang }) { const authorName = String.fromCharCode(77, 97, 104, 77, 85, 68); if (this.config.author !== authorName) { return api.sendMessage("You are not authorized to change the author name.", event.threadID, event.messageID); } const { senderID, threadID, messageID } = event; const outputPath = path.join(__dirname, "cache", `propose_${senderID}_${Date.now()}.png`); if (!fs.existsSync(path.dirname(outputPath))) fs.mkdirSync(path.dirname(outputPath), { recursive: true }); const mentions = Object.keys(event.mentions || {}); const reply = event.messageReply; let id1 = senderID, id2; if (mentions.length >= 2) { id1 = mentions[0]; id2 = mentions[1]; } else if (mentions.length === 1) { id2 = mentions[0]; } else if (reply && reply.senderID && reply.senderID !== senderID) { id2 = reply.senderID; } else if (args[0] && /^\d+$/.test(args[0])) { id2 = args[0]; } if (!id2) return api.sendMessage(getLang("noTarget"), threadID, messageID); try { api.setMessageReaction("💍", messageID, () => {}, true); const [userData1, userData2] = await Promise.all([usersData.get(id1), usersData.get(id2)]); let name1 = userData1.name, name2 = userData2.name; if (userData1.gender === 1 && id1 === senderID) { [id1, id2] = [id2, id1]; [name1, name2] = [name2, name1]; } const apiUrl = await baseApiUrl(); const { data } = await axios.get(`${apiUrl}/api/propose?user1=${id1}&user2=${id2}&style=2`, { responseType: "arraybuffer" }); fs.writeFileSync(outputPath, Buffer.from(data)); const percentage = Math.floor(Math.random() * 100) + 1; return api.sendMessage({ body: getLang("success", name1, name2, percentage), attachment: fs.createReadStream(outputPath) }, threadID, () => { api.setMessageReaction("✅", messageID, () => {}, true); if (fs.existsSync(outputPath)) fs.unlinkSync(outputPath); }, messageID); } catch (err) { api.setMessageReaction("❌", messageID, () => {}, true); if (fs.existsSync(outputPath)) fs.unlinkSync(outputPath); return api.sendMessage(getLang("error", err.message), threadID, messageID); } } };