// code from goatstore // api: https://store.agi.bd const axios = require('axios'); const fs = require('fs-extra'); module.exports = { config: { name: "rbg", aliases: [], author: "Hazeyy/kira", // hindi ito collab, ako kasi nag convert :> version: "69", cooldowns: 5, role: 0, shortDescription: { en: "Remove background in your photo" }, longDescription: { en: "Remove background in your photo" }, category: "img", guide: { en: "{p}{n} [reply to an img]" } }, onStart: async function({ api, event }) { const args = event.body.split(/\s+/); args.shift(); try { const response = await axios.get("https://hazeyy-apis-combine.kyrinwu.repl.co"); if (response.data.hasOwnProperty("error")) { return api.sendMessage(response.data.error, event.threadID, event.messageID); } let pathie = __dirname + `/cache/removed_bg.jpg`; const { threadID, messageID } = event; let photoUrl = event.messageReply ? event.messageReply.attachments[0].url : args.join(" "); if (!photoUrl) { api.sendMessage("πŸ“Έ π–―π—…π–Ύπ–Ίπ—Œπ–Ύ π—‹π–Ύπ—‰π—…π—Ž π—π—ˆ 𝖺 π—‰π—π—ˆπ—π—ˆ π—π—ˆ π—‰π—‹π—ˆπ–Όπ–Ύπ—Œπ—Œ 𝖺𝗇𝖽 π—‹π–Ύπ—†π—ˆπ—π–Ύ π–»π–Ίπ–Όπ—„π—€π—‹π—ˆπ—Žπ—‡π–½π—Œ.", threadID, messageID); return; } api.sendMessage("πŸ•Ÿ | π–±π–Ύπ—†π—ˆπ—π—‚π—‡π—€ π–‘π–Ίπ–Όπ—„π—€π—‹π—ˆπ—Žπ—‡π–½, π—‰π—…π–Ύπ–Ίπ—Œπ–Ύ 𝗐𝖺𝗂𝗍...", threadID, async () => { try { const response = await axios.get(`https://hazeyy-apis-combine.kyrinwu.repl.co/api/try/removebg?url=${encodeURIComponent(photoUrl)}`); const processedImageURL = response.data.image_data; const img = (await axios.get(processedImageURL, { responseType: "arraybuffer" })).data; fs.writeFileSync(pathie, Buffer.from(img, 'binary')); api.sendMessage({ body: "✨ 𝖧𝖾𝗋𝖾'π—Œ π—’π—ˆπ—Žπ—‹ 𝗂𝗆𝖺𝗀𝖾 π—π—‚π—π—π—ˆπ—Žπ— π–»πΊ°π–Ίπ–Όπ—„π—€π—‹π—ˆπ—Žπ—‡π–Ίπ–Ίπ–΄", attachment: fs.createReadStream(pathie) }, threadID, () => fs.unlinkSync(pathie), messageID); } catch (error) { api.sendMessage(`πŸ”΄ π–€π—‹π—‹π—ˆπ—‹ π—‰π—‹π—ˆπ–’π–Ύπ—Œπ—Œπ–¨π—‚π—†π–Ίπ–Ίπ–΄: ${error}`, threadID, messageID); } }); } catch (error) { api.sendMessage(`π–€π—‹π—‹π—ˆπ—‹: ${error.message}`, event.threadID, event.messageID); } } };