// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const https = require("https"); const API_URL = Buffer.from( "aHR0cHM6Ly9yYXNpbi1hcGlzLm9ucmVuZGVyLmNvbQ==", "base64" ).toString("utf8"); const API_KEY = Buffer.from( "cnNfaGVpNTJjbTgtbzRvai11Y2ZjLTR2N2MtZzE=", "base64" ).toString("utf8"); const http = axios.create({ timeout: 15000, maxRedirects: 5, httpsAgent: new https.Agent({ keepAlive: true }) }); async function downloadImage(url, filePath) { const response = await http.get(url, { responseType: "stream", timeout: 15000 }); await new Promise((resolve, reject) => { const writer = fs.createWriteStream(filePath); response.data.pipe(writer); writer.on("finish", () => { writer.close(resolve); }); writer.on("error", reject); response.data.on("error", reject); }); } module.exports = { config: { name: "needgf", version: "3.1.0", author: "Mûñtåsîr Asif ✦", countDown: 10, role: 0, shortDescription: "তোর Gf এর প্রোফাইল পিক দেখায় 😍", longDescription: "সিঙ্গেলদের জন্য মজার কমান্ড 💔 প্রতি বার API থেকে একটি নতুন প্রোফাইল ছবি দেখায়।", category: "fun" }, onStart: async function ({ message, event }) { const tmpDir = path.join(__dirname, "tmp"); const filePath = path.join( tmpDir, `${event.senderID}_${Date.now()}_gf.jpg` ); try { // Make sure tmp folder exists await fs.ensureDir(tmpDir); // Get image URL from API const response = await http.get( `${API_URL}/api/rasin/gf`, { params: { apikey: API_KEY } } ); const imgUrl = response.data?.data?.url; if (!imgUrl) { return message.reply( "⚠️ ছবি পাওয়া যায়নি ভাই 😭\nকিছুক্ষণ পর আবার চেষ্টা করো!" ); } // Download image await downloadImage(imgUrl, filePath); // Send image await message.reply({ body: "🌸✨ আপনার ভাগ্য জেগেছে ভাই!\n" + "এমন সুন্দরী গফ সবাই পায় না 💕\n" + "👇 নিচে দেখুন আপনার গফের প্রোফাইল 😚", attachment: fs.createReadStream(filePath) }); } catch (error) { console.error( "[NEEDGF ERROR]", error?.response?.data || error?.message || error ); await message.reply( "⚠️ সার্ভারে একটু সমস্যা হয়েছে ভাই 😭\n" + "কিছুক্ষণ পর আবার চেষ্টা করো!" ); } finally { // Always remove temporary image try { if (await fs.pathExists(filePath)) { await fs.remove(filePath); } } catch (cleanupError) { console.error( "[NEEDGF CLEANUP ERROR]", cleanupError.message ); } } } };