Created
December 27, 2025 16:47
-
-
Save manzxy/729af0869709b54c23403eed2d6f3965 to your computer and use it in GitHub Desktop.
Uploaded via YogiriMD
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
| /** | |
| • Fitur: Editimg (Fixed) | |
| • Sumber: https://whatsapp.com/channel/0029VbBS8ys0G0XnmJFRiV2v | |
| • Sumber Scrape: https://whatsapp.com/channel/0029Vap84RE8KMqfYnd0V41A/3590 | |
| • Note: Eror Lagi? Fix Sndirilah Cape Gw | |
| **/ | |
| import axios from "axios" | |
| import CryptoJS from "crypto-js" | |
| import fs from "fs" | |
| import path from "path" | |
| const AES_KEY = "ai-enhancer-web__aes-key" | |
| const AES_IV = "aienhancer-aesiv" | |
| function anu(obj) { | |
| return CryptoJS.AES.encrypt( | |
| JSON.stringify(obj), | |
| CryptoJS.enc.Utf8.parse(AES_KEY), | |
| { | |
| iv: CryptoJS.enc.Utf8.parse(AES_IV), | |
| mode: CryptoJS.mode.CBC, | |
| padding: CryptoJS.pad.Pkcs7 | |
| } | |
| ).toString() | |
| } | |
| async function pisang(filePath, prompt) { | |
| try { | |
| const img = fs.readFileSync(filePath, "base64") | |
| const settings = anu({ | |
| prompt, | |
| size: "2K", | |
| aspect_ratio: "match_input_image", | |
| output_format: "jpeg", | |
| max_images: 1 | |
| }) | |
| const headers = { | |
| "User-Agent": "Mozilla/5.0 (Linux; Android 10)", | |
| "Content-Type": "application/json", | |
| Origin: "https://aienhancer.ai", | |
| Referer: "https://aienhancer.ai/ai-image-editor" | |
| } | |
| const create = await axios.post( | |
| "https://aienhancer.ai/api/v1/k/image-enhance/create", | |
| { | |
| model: 2, | |
| image: `data:image/jpeg;base64,${img}`, | |
| settings | |
| }, | |
| { headers } | |
| ) | |
| const id = create?.data?.data?.id | |
| if (!id) throw new Error("Task ID tidak ditemukan") | |
| for (let i = 0; i < 10; i++) { | |
| await new Promise(r => setTimeout(r, 2500)) | |
| const r = await axios.post( | |
| "https://aienhancer.ai/api/v1/k/image-enhance/result", | |
| { task_id: id }, | |
| { headers } | |
| ) | |
| const data = r?.data?.data | |
| if (!data) continue | |
| if (data.status === "success") { | |
| return { | |
| id, | |
| output: data.output, | |
| input: data.input | |
| } | |
| } | |
| if (data.status === "failed") { | |
| throw new Error(data.error || "Proses gagal") | |
| } | |
| } | |
| throw new Error("Timeout proses terlalu lama") | |
| } catch (e) { | |
| throw e | |
| } | |
| } | |
| let handler = async (m, { conn, text }) => { | |
| const q = m.quoted || m | |
| const mime = (q.msg || q).mimetype || "" | |
| if (!mime.startsWith("image/")) | |
| return m.reply("❌ Kirim atau reply gambar\nContoh:\n.editimg ubah wajah jadi anime") | |
| if (!text) | |
| return m.reply("❌ Prompt wajib diisi\nContoh:\n.editimg ubah kulit jadi hitam") | |
| await m.react("🕒") | |
| try { | |
| const buffer = await q.download() | |
| if (!buffer) throw new Error("Gagal mengambil gambar") | |
| const tmpDir = path.join(process.cwd(), "tmp") | |
| if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir) | |
| const filePath = path.join(tmpDir, `${Date.now()}.jpg`) | |
| fs.writeFileSync(filePath, buffer) | |
| const result = await pisang(filePath, text) | |
| await conn.sendMessage( | |
| m.chat, | |
| { | |
| image: { url: result.output }, | |
| caption: "✨ Edit gambar berhasil" | |
| }, | |
| { quoted: m } | |
| ) | |
| fs.unlinkSync(filePath) | |
| } catch (e) { | |
| console.error(e) | |
| m.reply("❌ Gagal edit gambar") | |
| } | |
| } | |
| handler.help = ["editimg <prompt>"] | |
| handler.tags = ["ai"] | |
| handler.command = ["editimg","nanobanana"] | |
| handler.limit = 3 | |
| export default handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment