// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs"); const path = require("path"); const { createCanvas, loadImage } = require("canvas"); /** * @author Sakib * @author: do not delete it */ module.exports = { config: { name: "love", version: "3.0", author: "Sakib", countDown: 5, role: 0, longDescription: "Create a beautiful love image with two users", category: "love", guide: "{pn} @mention" }, onStart: async function ({ message, event, api }) { let imagePath = null; try { // ========================= // CHECK MENTION // ========================= const mentions = Object.keys(event.mentions || {}); if (mentions.length === 0) { return message.reply( "💞 | Please mention someone!\n\n" + "Example: love @someone" ); } const senderID = event.senderID; const targetID = mentions[0]; await message.reply( "💗 | তোমাদের Love Image তৈরি হচ্ছে..." ); // ========================= // GET USER INFORMATION // ========================= const userInfo = await new Promise((resolve, reject) => { api.getUserInfo( [senderID, targetID], (err, info) => { if (err) { return reject(err); } resolve(info); } ); }); if (!userInfo) { throw new Error("User information পাওয়া যায়নি।"); } const senderInfo = userInfo[senderID]; const targetInfo = userInfo[targetID]; if (!senderInfo || !targetInfo) { throw new Error( "দুইজনের profile information পাওয়া যায়নি।" ); } const senderName = senderInfo.name || "You"; const targetName = targetInfo.name || "Friend"; // ========================= // PROFILE PICTURE URL // ========================= const senderURL = senderInfo.profileUrl || `https://graph.facebook.com/${senderID}/picture?width=1000&height=1000`; const targetURL = targetInfo.profileUrl || `https://graph.facebook.com/${targetID}/picture?width=1000&height=1000`; // ========================= // DOWNLOAD PROFILE PICTURES // ========================= const [senderResponse, targetResponse] = await Promise.all([ axios.get(senderURL, { responseType: "arraybuffer", timeout: 20000, maxRedirects: 5 }), axios.get(targetURL, { responseType: "arraybuffer", timeout: 20000, maxRedirects: 5 }) ]); if ( !senderResponse.data || !targetResponse.data ) { throw new Error( "Profile picture download করা যায়নি।" ); } // ========================= // LOAD IMAGES // ========================= const senderImage = await loadImage( Buffer.from(senderResponse.data) ); const targetImage = await loadImage( Buffer.from(targetResponse.data) ); // ========================= // CANVAS // ========================= const WIDTH = 1200; const HEIGHT = 800; const canvas = createCanvas( WIDTH, HEIGHT ); const ctx = canvas.getContext("2d"); // ========================= // BACKGROUND // ========================= const background = ctx.createLinearGradient( 0, 0, WIDTH, HEIGHT ); background.addColorStop( 0, "#ff416c" ); background.addColorStop( 0.5, "#ff4b8b" ); background.addColorStop( 1, "#ff9a9e" ); ctx.fillStyle = background; ctx.fillRect( 0, 0, WIDTH, HEIGHT ); // ========================= // DECORATION // ========================= ctx.globalAlpha = 0.15; ctx.fillStyle = "#ffffff"; const circles = [ [100, 100, 120], [1100, 120, 150], [100, 700, 160], [1100, 700, 120] ]; for (const [x, y, r] of circles) { ctx.beginPath(); ctx.arc( x, y, r, 0, Math.PI * 2 ); ctx.fill(); } ctx.globalAlpha = 1; // ========================= // TITLE // ========================= ctx.textAlign = "center"; ctx.fillStyle = "#ffffff"; ctx.font = "bold 64px Arial"; ctx.fillText( "LOVE", WIDTH / 2, 85 ); // ========================= // IMAGE FUNCTION // ========================= function drawProfileImage( image, x, y, radius ) { ctx.save(); ctx.beginPath(); ctx.arc( x, y, radius, 0, Math.PI * 2 ); ctx.closePath(); ctx.clip(); const scale = Math.max( (radius * 2) / image.width, (radius * 2) / image.height ); const width = image.width * scale; const height = image.height * scale; ctx.drawImage( image, x - width / 2, y - height / 2, width, height ); ctx.restore(); // White border ctx.beginPath(); ctx.arc( x, y, radius, 0, Math.PI * 2 ); ctx.lineWidth = 14; ctx.strokeStyle = "#ffffff"; ctx.stroke(); } // ========================= // DRAW BOTH PHOTOS // ========================= drawProfileImage( senderImage, 340, 370, 185 ); drawProfileImage( targetImage, 860, 370, 185 ); // ========================= // HEART // ========================= ctx.fillStyle = "#ffffff"; ctx.font = "90px Arial"; ctx.fillText( "♥", WIDTH / 2, 400 ); // ========================= // NAMES // ========================= ctx.font = "bold 34px Arial"; ctx.fillText( senderName, 340, 620 ); ctx.fillText( targetName, 860, 620 ); // ========================= // BOTTOM TEXT // ========================= ctx.font = "bold 32px Arial"; ctx.fillText( "Together • Forever ❤️", WIDTH / 2, 735 ); // ========================= // SAVE IMAGE // ========================= imagePath = path.join( __dirname, `love_${senderID}_${targetID}_${Date.now()}.png` ); const imageBuffer = canvas.toBuffer( "image/png" ); fs.writeFileSync( imagePath, imageBuffer ); // ========================= // SEND IMAGE // ========================= await message.reply({ body: `💞 | ${senderName} ❤️ ${targetName}\n` + `✨ | Love Image তৈরি হয়েছে!\n` + `👑 | Made by Sakib`, attachment: fs.createReadStream( imagePath ) }); // ========================= // DELETE TEMP FILE // ========================= setTimeout(() => { try { if ( imagePath && fs.existsSync(imagePath) ) { fs.unlinkSync( imagePath ); } } catch (error) { console.error( "Temporary file delete error:", error.message ); } }, 15000); } catch (error) { console.error( "LOVE COMMAND ERROR:", error ); // Delete file if error happens if ( imagePath && fs.existsSync(imagePath) ) { try { fs.unlinkSync( imagePath ); } catch (e) {} } return message.reply( "❌ | Love image তৈরি করা যায়নি।\n\n" + "📄 | Error: " + (error.message || "Unknown error") ); } } };