// code from goatstore // api: https://store.agi.bd const fs = require("fs"); const os = require("os"); const path = require("path"); const Canvas = require("canvas"); const GIFEncoder = require("gif-encoder-2"); module.exports = { config: { name: "up2", aliases: ["up2"], version: "2.0.0", author: "Zihad Kazi", countDown: 10, role: 0, shortDescription: { en: "Animated live uptime" }, longDescription: { en: "Shows live animated uptime, CPU and RAM status." }, category: "system" }, onStart: async function ({ api, event }) { const width = 900; const height = 500; const encoder = new GIFEncoder(width, height); encoder.setDelay(250); encoder.setRepeat(0); encoder.setQuality(10); const temp = path.join( __dirname, `uptime_${Date.now()}.gif` ); const stream = encoder.createReadStream(); const output = fs.createWriteStream(temp); stream.pipe(output); const canvas = Canvas.createCanvas(width, height); const ctx = canvas.getContext("2d"); const start = Date.now(); function formatUptime(sec) { sec = Math.floor(sec); const d = Math.floor(sec / 86400); const h = Math.floor((sec % 86400) / 3600); const m = Math.floor((sec % 3600) / 60); const s = sec % 60; return `${d}d ${String(h).padStart(2, "0")}h ${String(m).padStart(2, "0")}m ${String(s).padStart(2, "0")}s`; } function drawRoundRect(x, y, w, h, r) { ctx.beginPath(); ctx.moveTo(x + r, y); ctx.lineTo(x + w - r, y); ctx.quadraticCurveTo(x + w, y, x + w, y + r); ctx.lineTo(x + w, y + h - r); ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); ctx.lineTo(x + r, y + h); ctx.quadraticCurveTo(x, y + h, x, y + h - r); ctx.lineTo(x, y + r); ctx.quadraticCurveTo(x, y, x + r, y); ctx.closePath(); } function getCPU() { const cpus = os.cpus(); let idle = 0; let total = 0; for (const cpu of cpus) { idle += cpu.times.idle; total += cpu.times.user + cpu.times.nice + cpu.times.sys + cpu.times.irq + cpu.times.idle; } if (!total) return 0; return Math.min( 100, Math.max(0, 100 - (idle / total) * 100) ); } for (let frame = 0; frame < 32; frame++) { const uptime = process.uptime(); const totalRAM = os.totalmem(); const freeRAM = os.freemem(); const ram = ((totalRAM - freeRAM) / totalRAM) * 100; const cpu = getCPU(); // Background const bg = ctx.createLinearGradient( 0, 0, width, height ); bg.addColorStop(0, "#080511"); bg.addColorStop(0.5, "#160a25"); bg.addColorStop(1, "#05030b"); ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height); // Purple glow const glow = ctx.createRadialGradient( 450, 0, 20, 450, 0, 450 ); glow.addColorStop(0, "rgba(190,70,255,.45)"); glow.addColorStop(1, "rgba(190,70,255,0)"); ctx.fillStyle = glow; ctx.fillRect(0, 0, width, height); // Main border ctx.strokeStyle = "#63358a"; ctx.lineWidth = 3; drawRoundRect( 20, 20, width - 40, height - 40, 25 ); ctx.stroke(); // Header ctx.font = "bold 30px Arial"; ctx.fillStyle = "#ffffff"; ctx.fillText("⚡ ELECTRA", 50, 70); ctx.font = "16px Arial"; ctx.fillStyle = "#8dffcf"; ctx.fillText("● LIVE SYSTEM MONITOR", 650, 68); // Uptime card ctx.fillStyle = "#120b1d"; drawRoundRect( 50, 105, 800, 130, 18 ); ctx.fill(); ctx.strokeStyle = "#352442"; ctx.stroke(); ctx.font = "18px Arial"; ctx.fillStyle = "#aaa0b5"; ctx.fillText("SERVER UPTIME", 80, 140); ctx.font = "bold 40px Arial"; ctx.fillStyle = "#ffffff"; ctx.fillText( formatUptime(uptime), 80, 190 ); // Online indicator ctx.beginPath(); ctx.arc(770, 160, 12, 0, Math.PI * 2); const pulse = Math.sin(frame * 0.7) > 0 ? "#62ffc7" : "#20a87c"; ctx.fillStyle = pulse; ctx.shadowBlur = 25; ctx.shadowColor = "#62ffc7"; ctx.fill(); ctx.shadowBlur = 0; ctx.font = "bold 18px Arial"; ctx.fillStyle = "#62ffc7"; ctx.fillText("ONLINE", 690, 205); // CPU card ctx.fillStyle = "#120b1d"; drawRoundRect( 50, 260, 380, 170, 18 ); ctx.fill(); ctx.strokeStyle = "#352442"; ctx.stroke(); ctx.font = "bold 20px Arial"; ctx.fillStyle = "#ffffff"; ctx.fillText("CPU LOAD", 80, 300); ctx.font = "bold 42px Arial"; ctx.fillStyle = "#db72ff"; ctx.fillText( `${cpu.toFixed(1)}%`, 80, 355 ); // CPU bar ctx.fillStyle = "#281a36"; drawRoundRect( 80, 380, 300, 18, 9 ); ctx.fill(); ctx.fillStyle = "#bd5cff"; drawRoundRect( 80, 380, 300 * (cpu / 100), 18, 9 ); ctx.fill(); // RAM card ctx.fillStyle = "#120b1d"; drawRoundRect( 470, 260, 380, 170, 18 ); ctx.fill(); ctx.strokeStyle = "#352442"; ctx.stroke(); ctx.font = "bold 20px Arial"; ctx.fillStyle = "#ffffff"; ctx.fillText("MEMORY", 500, 300); ctx.font = "bold 42px Arial"; ctx.fillStyle = "#62ffc7"; ctx.fillText( `${ram.toFixed(1)}%`, 500, 355 ); // RAM bar ctx.fillStyle = "#16332d"; drawRoundRect( 500, 380, 300, 18, 9 ); ctx.fill(); ctx.fillStyle = "#45e9b2"; drawRoundRect( 500, 380, 300 * (ram / 100), 18, 9 ); ctx.fill(); // Footer ctx.font = "14px Arial"; ctx.fillStyle = "#71657d"; ctx.fillText( `Node ${process.version} • ${os.platform()} • ${os.cpus().length} CPU cores`, 50, 465 ); encoder.addFrame(ctx); // প্রতি frame-এ uptime update হবে await new Promise(resolve => setTimeout(resolve, 250) ); } encoder.finish(); await new Promise(resolve => { output.on("finish", resolve); }); return api.sendMessage( { body: "⚡ LIVE UPTIME\n\n🟢 All systems operational", attachment: fs.createReadStream(temp) }, event.threadID, () => { try { fs.unlinkSync(temp); } catch {} }, event.messageID ); } };