Created
April 21, 2026 13:01
-
-
Save ayashiiiyo/f0be31f25c779034d1108c1f7b944595 to your computer and use it in GitHub Desktop.
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
| async function img2img(prompt, imageUrl) { | |
| const start = await fetch(`https://fgsi.dpdns.org/api/ai/image/img2img?apikey=APIKEY_MU&prompt=${encodeURIComponent(prompt)}&url=${encodeURIComponent(imageUrl)}`).then(r => r.json()) | |
| let result | |
| while (true) { | |
| const poll = await fetch(start.data.pollUrl).then(r => r.json()) | |
| if (!poll.status) throw new Error('Polling gagal') | |
| if (poll.data.status === 'Success') { | |
| result = poll.data.result | |
| break | |
| } | |
| await new Promise(r => setTimeout(r, 2000)) | |
| } | |
| return result | |
| } | |
| async function Uguu(buffer, filename) { | |
| const form = new FormData() | |
| form.append('files[]', new Blob([buffer]), filename) | |
| const data = await fetch('https://uguu.se/upload.php', { | |
| method: 'POST', | |
| body: form | |
| }).then(r => r.json()) | |
| if (data.files && data.files[0]) { | |
| return { url: data.files[0].url } | |
| } else { | |
| throw new Error('Upload gagal.') | |
| } | |
| } | |
| let handler = async (m, { conn, text }) => { | |
| try { | |
| const q = m.quoted ? m.quoted : m | |
| const mime = (q.msg || q).mimetype || '' | |
| if (!mime.startsWith('image/')) return m.reply('Mana gambarnya') | |
| m.reply(global.wait) | |
| const out = await img2img( | |
| text, | |
| (await Uguu(await q.download(), `upload.${mime.split('/')[1]}`)).url | |
| ) | |
| const buffer = await fetch(out.url).then(r => r.arrayBuffer()) | |
| await conn.sendMessage( | |
| m.chat, | |
| { image: Buffer.from(buffer) }, | |
| { quoted: m } | |
| ) | |
| } catch (e) { | |
| m.reply(e.message) | |
| } | |
| } | |
| handler.help = ['editimg', 'img2img'] | |
| handler.command = ['editimg', 'img2img'] | |
| handler.tags = ['ai'] | |
| export default handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment