// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "dubai", aliases: ["uae"], version: "1.3.0", author: "EryXenX", countDown: 5, role: 0, shortDescription: "UAE Driving License Card Maker", longDescription: "Generate a custom UAE Driving License identity card image with details.", category: "image", guide: { en: "{p}dubai Name - Date of Birth - Arabic Name - License No" } }, onStart: async function ({ api, event, args }) { const { threadID, messageID, senderID } = event; if (args.length === 0) { const usageGuide = "⚠️ Please enter details in the correct format!\n\n" + "📌 Usage:\n" + "dubai Name - Date of Birth - Arabic Name - 7-digit License No\n\n" + "💡 Example:\n" + "dubai Akash Chowdhury - 10/12/2007 - أكاش تشودري - 4596279"; return api.sendMessage(usageGuide, threadID, messageID); } try { const input = args.join(" ").split("-").map(item => item.trim()); const engName = input[0] || "Akash Chowdhury"; const dob = input[1] || "10/12/2007"; const arbName = input[2] || "أكاش تشودري"; const licenseNo = input[3] || "4596279"; let res; for (let i = 0; i < 2; i++) { try { res = await axios.get("https://eryxenx.agi.bd/api/uaelicence", { params: { apikey: "eryx_96cb9c4c1ef12faeabf2c564c53d7e1b", name: engName, dob: dob, arabic: arbName, license: licenseNo }, responseType: "arraybuffer", timeout: 120000 }); break; } catch (err) { const status = err.response && err.response.status; if (status && status < 500) throw err; if (i === 1) throw err; await new Promise(resolve => setTimeout(resolve, 3000)); } } if (!String(res.headers["content-type"]).startsWith("image/")) { throw new Error("Unexpected response from API"); } const cacheDir = path.join(__dirname, "tmp"); if (!fs.existsSync(cacheDir)) { fs.mkdirSync(cacheDir, { recursive: true }); } const pathImg = path.join(cacheDir, `card_${senderID}.jpg`); fs.writeFileSync(pathImg, Buffer.from(res.data)); return api.sendMessage({ body: "✅ Driving License Card generated successfully!", attachment: fs.createReadStream(pathImg) }, threadID, () => { if (fs.existsSync(pathImg)) fs.unlinkSync(pathImg); }, messageID); } catch (e) { console.error("Dubai command error:", e); let msg = e.message; if (e.response && e.response.data) { try { msg = JSON.parse(Buffer.from(e.response.data).toString()).error || msg; } catch (parseErr) {} } return api.sendMessage("❌ Error: " + msg, threadID, messageID); } } };