Created
December 31, 2025 14:40
-
-
Save ONLym22/f3be133f6f8f23e91ab5f4731b347cf8 to your computer and use it in GitHub Desktop.
Uploaded via ONLym Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // π Source: JavaScript | |
| case "removebg": | |
| case "rb": { | |
| const q = m.quoted ? m.quoted : m; | |
| const mime = (q.msg || q).mimetype || ""; | |
| if (!/image/.test(mime)) { | |
| return xreply(`Kirim atau balas *gambar* dengan perintah *${prefix + command}*`); | |
| } | |
| if (!global.onlym) { | |
| return xreply("β API key belum dikonfigurasi. Selesaikan pengaturan di index.js terlebih dahulu."); | |
| } | |
| xreact(); | |
| try { | |
| const media = await vellia.downloadAndSaveMediaMessage(q); | |
| const catBoxUrl = await uploadCatBox(media); | |
| if (fs.existsSync(media)) fs.unlinkSync(media); | |
| if (!catBoxUrl) { | |
| return xreply("β Gagal mengunggah gambar ke server penyimpanan (Catbox)."); | |
| } | |
| const apiUrl = `https://onlym.my.id/tools/removebg?url=${catBoxUrl}&apikey=${global.onlym}`; | |
| const apiRes = await axios.get(apiUrl, { | |
| responseType: "arraybuffer", | |
| timeout: 60000 | |
| }); | |
| if (!apiRes.data || apiRes.data.byteLength < 100) { | |
| return xreply("β Gagal memproses gambar. API mengembalikan hasil kosong."); | |
| } | |
| await vellia.sendMessage(m.chat, { | |
| image: Buffer.from(apiRes.data), | |
| caption: `β¨ *Background Removed*\n\n` + | |
| `π *Engine:* ONLym Tools\n` + | |
| `π *Api:* https://onlym.my.id/\n\n` + | |
| `${global.wm}` | |
| }, { quoted: qkontak }); | |
| xreact("β "); | |
| } catch (err) { | |
| console.error("[REMOVEBG ERROR]", err.message); | |
| const errMsg = err.response?.status === 403 | |
| ? "β οΈ API Key tidak valid atau limit habis." | |
| : "β οΈ Gagal menghapus background. Pastikan subjek gambar jelas."; | |
| xreply(errMsg); | |
| xreact("β"); | |
| } | |
| } | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment