// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const axios = require("axios"); const canvas = require("canvas"); const path = require("path"); // ===== সেটিংস ===== const COOLDOWN_MS = 60 * 1000; // ১ জন ইউজার ১ মিনিটে ১ বার const TEMPLATE_URL = "https://i.imgur.com/e5atThp.jpeg"; // টেমপ্লেটের রেফারেন্স মাপ const REF = { w: 1024, h: 1536 }; // উপরের ডান গোল (দাঁড়ানো ছেলে) = যে কমান্ড দিয়েছে সে const SENDER_CIRCLE = { cx: 817, cy: 238, r: 85 }; // নিচের বাম গোল (পা ধরা ছেলে) = টার্গেট const TARGET_CIRCLE = { cx: 259, cy: 755, r: 81 }; // ================== const lastUsed = new Map(); module.exports = { config: { name: "pem", version: "1.1.0", author: "乛 M polaris R ཐི༏ཋྀ JU polaris W polaris ELꜛཐི༏ཋྀ࿐", countDown: 0, role: 0, shortDescription: "প্রেম মিম টেমপ্লেট (পা ধরে প্রেম ভিক্ষা)", longDescription: "প্রেম মিম টেমপ্লেট (পা ধরে প্রেম ভিক্ষা)", category: "image", guide: "{pn} [@mention / reply]" }, onStart: async function ({ event, api, message }) { const senderID = String(event.senderID); // টার্গেট: মেনশন > রিপ্লাই > নিজে const targetUserId = String( Object.keys(event.mentions || {})[0] || (event.messageReply && event.messageReply.senderID) || event.senderID ); // কুলডাউন const now = Date.now(); const last = lastUsed.get(senderID) || 0; const wait = COOLDOWN_MS - (now - last); if (wait > 0) { return message.reply( `⏳ ${Math.ceil(wait / 1000)} সেকেন্ড পরে আবার চেষ্টা কর।` ); } lastUsed.set(senderID, now); const cacheDir = path.join(__dirname, "cache"); const outputPath = path.join(cacheDir, `pem_${Date.now()}.jpg`); // প্রোফাইল ছবি আনার ফাংশন async function getAvatar(uid) { try { const res = await axios.get( `https://graph.facebook.com/${uid}/picture?width=512&height=512&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`, { responseType: "arraybuffer", headers: { "User-Agent": "Mozilla/5.0" }, timeout: 15000 } ); return canvas.loadImage(Buffer.from(res.data)); } catch (e) { // ব্যাকআপ const info = await new Promise((resolve, reject) => { api.getUserInfo(uid, (err, res) => (err ? reject(err) : resolve(res))); }); const thumb = info[uid]?.thumbSrc; if (!thumb) throw new Error("Profile picture not found"); const r2 = await axios.get(thumb, { responseType: "arraybuffer", timeout: 15000 }); return canvas.loadImage(Buffer.from(r2.data)); } } try { await fs.ensureDir(cacheDir); // টেমপ্লেট const templateRes = await axios.get(TEMPLATE_URL, { responseType: "arraybuffer", headers: { "User-Agent": "Mozilla/5.0" }, timeout: 20000 }); const templateImage = await canvas.loadImage(Buffer.from(templateRes.data)); const [targetAvatar, senderAvatar] = await Promise.all([ getAvatar(targetUserId), getAvatar(senderID) ]); const cv = canvas.createCanvas(templateImage.width, templateImage.height); const ctx = cv.getContext("2d"); ctx.drawImage(templateImage, 0, 0); // স্কেল const kx = templateImage.width / REF.w; const ky = templateImage.height / REF.h; function drawCircle(img, c) { const cx = c.cx * kx; const cy = c.cy * ky; const r = c.r * kx; ctx.save(); ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.closePath(); ctx.clip(); ctx.drawImage(img, cx - r, cy - r, r * 2, r * 2); ctx.restore(); // সাদা বর্ডার ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.lineWidth = 5 * kx; ctx.strokeStyle = "#ffffff"; ctx.stroke(); } drawCircle(targetAvatar, TARGET_CIRCLE); drawCircle(senderAvatar, SENDER_CIRCLE); await fs.writeFile(outputPath, cv.toBuffer("image/jpeg")); // শুধু ফটো পাঠানো await message.reply({ attachment: fs.createReadStream(outputPath) }); // ফাইল ডিলিট setTimeout(() => { fs.unlink(outputPath).catch(() => {}); }, 15000); } catch (error) { lastUsed.delete(senderID); console.error("[PEM ERROR]", error); return message.reply("Error: " + error.message); } } };