// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const { loadImage, createCanvas } = require("canvas"); module.exports = { config: { name: "password", version: "2.1.0", author: "tdunguwu → Goat Bot V2", countDown: 10, role: 0, shortDescription: { en: "Create password image" }, longDescription: { en: "Create a password style image using two texts." }, category: "game", guide: { en: "{pn} text 1 | text 2" } }, // ═════════════════════════════════════════════ // 📝 TEXT WRAP // ═════════════════════════════════════════════ wrapText(ctx, text, maxWidth) { const words = text.split(/\s+/); const lines = []; let line = ""; for (const word of words) { const testLine = line ? `${line} ${word}` : word; if (ctx.measureText(testLine).width <= maxWidth) { line = testLine; } else { if (line) { lines.push(line); } // বড় শব্দ হলে character অনুযায়ী ভাগ if (ctx.measureText(word).width > maxWidth) { let temp = ""; for (const char of word) { const test = temp + char; if ( ctx.measureText(test).width <= maxWidth ) { temp = test; } else { if (temp) lines.push(temp); temp = char; } } line = temp; } else { line = word; } } } if (line) { lines.push(line); } return lines; }, // ═════════════════════════════════════════════ // 🚀 COMMAND // ═════════════════════════════════════════════ onStart: async function ({ api, event, args }) { const { threadID, messageID } = event; const input = args .join(" ") .trim(); // ───────────── Check Input ───────────── if (!input.includes("|")) { return api.sendMessage( "❌ সঠিক format ব্যবহার করুন:\n\npassword Text 1 | Text 2\n\nউদাহরণ:\npassword Hello | 123456", threadID, messageID ); } const parts = input .split("|") .map(text => text.trim()); const text1 = parts[0]; const text2 = parts.slice(1).join(" | ").trim(); if (!text1 || !text2) { return api.sendMessage( "❌ দুই পাশে text দিতে হবে!\n\nউদাহরণ:\npassword Hello | World", threadID, messageID ); } const cacheDir = path.join( __dirname, "cache" ); await fs.ensureDir(cacheDir); const filePath = path.join( cacheDir, `password_${Date.now()}.png` ); try { // ═══════════════════════════════════════════ // 🖼️ DOWNLOAD BASE IMAGE // ═══════════════════════════════════════════ const imageURL = "https://i.imgur.com/QkddlpG.png"; const response = await axios.get( imageURL, { responseType: "arraybuffer", timeout: 30000, headers: { "User-Agent": "Mozilla/5.0" } } ); await fs.writeFile( filePath, Buffer.from(response.data) ); // ═══════════════════════════════════════════ // 🎨 LOAD IMAGE // ═══════════════════════════════════════════ const baseImage = await loadImage( filePath ); const canvas = createCanvas( baseImage.width, baseImage.height ); const ctx = canvas.getContext("2d"); ctx.drawImage( baseImage, 0, 0, canvas.width, canvas.height ); // ═══════════════════════════════════════════ // ✍️ FONT // ═══════════════════════════════════════════ ctx.font = "30px Arial"; ctx.fillStyle = "#000000"; ctx.textAlign = "center"; ctx.textBaseline = "alphabetic"; const lineHeight = 35; // ═══════════════════════════════════════════ // 📝 FIRST TEXT // ═══════════════════════════════════════════ const firstLines = this.wrapText( ctx, text1, 464 ); firstLines.forEach((line, index) => { ctx.fillText( line, 320, 129 + index * lineHeight ); }); // ═══════════════════════════════════════════ // 📝 SECOND TEXT // ═══════════════════════════════════════════ const secondLines = this.wrapText( ctx, text2, 464 ); secondLines.forEach((line, index) => { ctx.fillText( line, 330, 380 + index * lineHeight ); }); // ═══════════════════════════════════════════ // 💾 SAVE // ═══════════════════════════════════════════ const buffer = canvas.toBuffer("image/png"); await fs.writeFile( filePath, buffer ); // ═══════════════════════════════════════════ // 📤 SEND // ═══════════════════════════════════════════ await api.sendMessage( { attachment: fs.createReadStream( filePath ) }, threadID, messageID ); } catch (error) { console.error( "\n========== PASSWORD ERROR ==========\n", error, "\n====================================\n" ); return api.sendMessage( `❌ Image তৈরি করতে সমস্যা হয়েছে!\n\nError: ${error.message}`, threadID, messageID ); } finally { // ═══════════════════════════════════════════ // 🗑️ DELETE CACHE // ═══════════════════════════════════════════ setTimeout(async () => { try { if ( await fs.pathExists(filePath) ) { await fs.remove(filePath); } } catch (err) { console.error( "Cache delete error:", err ); } }, 5000); } } };