// code from goatstore // api: https://store.agi.bd module.exports.config = { name: "up2", version: "5.0.0", author: "Zihad • Premium Real Uptime", aliases: ["upt", "up2"], role: 0, category: "system", guide: "{pn}" }; const { createCanvas } = require("canvas"); const fs = require("fs-extra"); const path = require("path"); const os = require("os"); module.exports.onStart = async function ({ api, event }) { try { // ============================== // REAL BOT PROCESS UPTIME // ============================== const getUptime = () => { return Math.floor(process.uptime()); }; const formatUptime = (seconds) => { seconds = Math.max(0, Math.floor(seconds)); const days = Math.floor(seconds / 86400); seconds %= 86400; const hours = Math.floor(seconds / 3600); seconds %= 3600; const minutes = Math.floor(seconds / 60); const secs = seconds % 60; return ( days + "d " + String(hours).padStart(2, "0") + "h " + String(minutes).padStart(2, "0") + "m " + String(secs).padStart(2, "0") + "s" ); }; // ============================== // BYTE FORMAT // ============================== const formatBytes = (bytes) => { if (!bytes || bytes <= 0) return "0 MB"; const units = [ "B", "KB", "MB", "GB", "TB" ]; let i = 0; let value = Number(bytes); while ( value >= 1024 && i < units.length - 1 ) { value /= 1024; i++; } return ( value.toFixed(i === 0 ? 0 : 1) + " " + units[i] ); }; // ============================== // MEMORY // ============================== const getMemory = () => { try { const total = os.totalmem(); const free = os.freemem(); const used = total - free; return { total, free, used, percent: total > 0 ? (used / total) * 100 : 0 }; } catch (e) { return { total: 0, free: 0, used: 0, percent: 0 }; } }; // ============================== // CPU // ============================== const getCPU = () => { try { const cpus = os.cpus(); if (!cpus || !cpus.length) { return 0; } let idle = 0; let total = 0; for (const cpu of cpus) { const t = cpu.times; idle += Number(t.idle || 0); total += Number(t.user || 0) + Number(t.nice || 0) + Number(t.sys || 0) + Number(t.idle || 0) + Number(t.irq || 0); } if (!total) return 0; const usage = 100 - (idle / total) * 100; return Math.max( 0, Math.min(100, usage) ); } catch (e) { return 0; } }; // ============================== // DISK // ============================== const getDisk = () => { try { if ( typeof fs.statfsSync !== "function" ) { return { total: 0, used: 0, free: 0, percent: 0 }; } const root = process.platform === "win32" ? "C:\\" : "/"; const stat = fs.statfsSync(root); const blockSize = Number( stat.bsize || stat.frsize || 0 ); const total = Number(stat.blocks || 0) * blockSize; const free = Number( stat.bavail ?? stat.bfree ?? 0 ) * blockSize; const used = Math.max( 0, total - free ); return { total, used, free, percent: total > 0 ? (used / total) * 100 : 0 }; } catch (e) { return { total: 0, used: 0, free: 0, percent: 0 }; } }; // ============================== // DRAW HELPERS // ============================== const roundRect = ( ctx, x, y, w, h, r ) => { r = Math.min( r, w / 2, h / 2 ); 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(); }; const drawIconBox = ( ctx, x, y, color ) => { ctx.save(); ctx.fillStyle = "rgba(235,240,255,0.85)"; roundRect( ctx, x, y, 58, 58, 18 ); ctx.fill(); ctx.fillStyle = color; roundRect( ctx, x + 17, y + 13, 24, 31, 5 ); ctx.fill(); ctx.restore(); }; const drawClock = ( ctx, x, y ) => { ctx.save(); ctx.strokeStyle = "#4D72E8"; ctx.lineWidth = 7; ctx.beginPath(); ctx.arc( x, y, 29, 0, Math.PI * 2 ); ctx.stroke(); ctx.lineCap = "round"; ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x, y - 16); ctx.moveTo(x, y); ctx.lineTo(x + 13, y + 7); ctx.stroke(); ctx.restore(); }; const drawBot = ( ctx, x, y ) => { ctx.save(); ctx.fillStyle = "#5574E8"; roundRect( ctx, x - 28, y - 18, 56, 43, 12 ); ctx.fill(); // Antenna ctx.strokeStyle = "#5574E8"; ctx.lineWidth = 5; ctx.beginPath(); ctx.moveTo( x, y - 18 ); ctx.lineTo( x, y - 31 ); ctx.stroke(); ctx.beginPath(); ctx.arc( x, y - 35, 5, 0, Math.PI * 2 ); ctx.fill(); // Eyes ctx.fillStyle = "#FFFFFF"; ctx.beginPath(); ctx.arc( x - 11, y - 1, 4, 0, Math.PI * 2 ); ctx.arc( x + 11, y - 1, 4, 0, Math.PI * 2 ); ctx.fill(); // Mouth ctx.strokeStyle = "#FFFFFF"; ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo( x - 9, y + 12 ); ctx.lineTo( x + 9, y + 12 ); ctx.stroke(); // Side antennas ctx.strokeStyle = "#5574E8"; ctx.lineWidth = 4; ctx.beginPath(); ctx.moveTo( x - 28, y - 4 ); ctx.lineTo( x - 37, y - 4 ); ctx.moveTo( x + 28, y - 4 ); ctx.lineTo( x + 37, y - 4 ); ctx.stroke(); ctx.restore(); }; const drawStatusDot = ( ctx, x, y, radius, color ) => { ctx.save(); ctx.fillStyle = color; ctx.beginPath(); ctx.arc( x, y, radius, 0, Math.PI * 2 ); ctx.fill(); ctx.restore(); }; const drawBar = ( ctx, x, y, w, h, percent, color ) => { percent = Math.max( 0, Math.min( 100, Number(percent) || 0 ) ); roundRect( ctx, x, y, w, h, h / 2 ); ctx.fillStyle = "#E5E9F6"; ctx.fill(); if (percent <= 0) return; const fillW = Math.max( h, (w * percent) / 100 ); roundRect( ctx, x, y, Math.min(w, fillW), h, h / 2 ); ctx.fillStyle = color; ctx.fill(); }; // ============================== // SYSTEM DATA // ============================== const uptime = getUptime(); const cpu = getCPU(); const memory = getMemory(); const disk = getDisk(); const cores = os.cpus() && os.cpus().length ? os.cpus().length : 0; const width = 1280; const height = 760; // ============================== // CANVAS // ============================== const canvas = createCanvas( width, height ); const ctx = canvas.getContext("2d"); // ============================== // BACKGROUND // ============================== const background = ctx.createLinearGradient( 0, 0, width, height ); background.addColorStop( 0, "#F2F4FF" ); background.addColorStop( 0.5, "#F8F9FF" ); background.addColorStop( 1, "#FFF8FC" ); ctx.fillStyle = background; ctx.fillRect( 0, 0, width, height ); // ============================== // MAIN PANEL // ============================== ctx.save(); ctx.shadowColor = "rgba(85,100,180,0.15)"; ctx.shadowBlur = 35; ctx.shadowOffsetY = 18; roundRect( ctx, 35, 45, 1210, 665, 42 ); ctx.fillStyle = "rgba(255,255,255,0.94)"; ctx.fill(); ctx.restore(); // ============================== // HEADER BOT ICON // ============================== drawBot( ctx, 128, 225 ); ctx.fillStyle = "#101735"; ctx.font = "bold 44px Sans"; ctx.fillText( "UPTIME", 210, 115 ); ctx.fillStyle = "#7881A6"; ctx.font = "20px Sans"; ctx.fillText( "Real-time bot process information", 212, 145 ); // ============================== // ONLINE BADGE // ============================== roundRect( ctx, 990, 78, 185, 62, 32 ); ctx.fillStyle = "#EDF9F1"; ctx.fill(); drawStatusDot( ctx, 1030, 109, 13, "#35B85B" ); ctx.fillStyle = "#3EA95B"; ctx.font = "bold 19px Sans"; ctx.fillText( "ONLINE", 1055, 116 ); // ============================== // UPTIME HERO // ============================== ctx.save(); ctx.shadowColor = "rgba(70,95,180,0.08)"; ctx.shadowBlur = 15; roundRect( ctx, 75, 190, 1130, 190, 28 ); const hero = ctx.createLinearGradient( 75, 190, 1205, 380 ); hero.addColorStop( 0, "#EEF3FF" ); hero.addColorStop( 1, "#DDE7FF" ); ctx.fillStyle = hero; ctx.fill(); ctx.restore(); // Clock icon area roundRect( ctx, 100, 225, 125, 120, 35 ); ctx.fillStyle = "rgba(235,241,255,0.85)"; ctx.fill(); drawClock( ctx, 162, 285 ); // Hero text ctx.fillStyle = "#7180A5"; ctx.font = "bold 18px Sans"; ctx.fillText( "REAL BOT UPTIME", 250, 245 ); ctx.fillStyle = "#0D1737"; ctx.font = "bold 52px Sans"; ctx.fillText( formatUptime(uptime), 250, 305 ); ctx.fillStyle = "#7180A5"; ctx.font = "18px Sans"; ctx.fillText( "Node.js process.uptime()", 250, 338 ); // Decorative circles ctx.save(); ctx.globalAlpha = 0.4; ctx.fillStyle = "#C6D5FF"; ctx.beginPath(); ctx.arc( 1110, 355, 95, Math.PI, Math.PI * 2 ); ctx.fill(); ctx.beginPath(); ctx.arc( 1030, 385, 70, Math.PI, Math.PI * 2 ); ctx.fill(); ctx.restore(); // ============================== // STAT CARDS // ============================== const cardY = 405; const cardW = 250; const cardH = 160; const statCards = [ { x: 75, title: "CPU", value: cpu.toFixed(1) + "%", sub: "Processor usage", color: "#4C6FE8", icon: "#4C6FE8", percent: cpu }, { x: 365, title: "MEMORY", value: memory.percent.toFixed(1) + "%", sub: formatBytes(memory.used) + " / " + formatBytes(memory.total), color: "#36B965", icon: "#36B965", percent: memory.percent }, { x: 655, title: "CORE", value: String(cores), sub: "CPU cores", color: "#7358D9", icon: "#7358D9", percent: Math.min( 100, cores * 2 ) }, { x: 945, title: "DISK", value: disk.percent.toFixed(1) + "%", sub: formatBytes(disk.used) + " / " + formatBytes(disk.total), color: "#F0A719", icon: "#F0A719", percent: disk.percent } ]; for (const card of statCards) { ctx.save(); ctx.shadowColor = "rgba(70,80,130,0.09)"; ctx.shadowBlur = 16; ctx.shadowOffsetY = 5; roundRect( ctx, card.x, cardY, cardW, cardH, 24 ); ctx.fillStyle = "#FFFFFF"; ctx.fill(); ctx.restore(); // Icon roundRect( ctx, card.x + 22, cardY + 20, 58, 58, 17 ); ctx.fillStyle = card.color === "#36B965" ? "#EDF9F1" : card.color === "#F0A719" ? "#FFF6E5" : card.color === "#7358D9" ? "#F0EDFF" : "#EEF2FF"; ctx.fill(); // Icon symbol ctx.fillStyle = card.icon; ctx.font = "bold 25px Sans"; ctx.textAlign = "center"; ctx.fillText( card.title === "CPU" ? "▦" : card.title === "MEMORY" ? "●" : card.title === "CORE" ? "▣" : "●", card.x + 51, cardY + 57 ); ctx.textAlign = "left"; // Title ctx.fillStyle = "#7881A2"; ctx.font = "bold 18px Sans"; ctx.fillText( card.title, card.x + 95, cardY + 52 ); // Value ctx.fillStyle = "#0D1737"; ctx.font = "bold 39px Sans"; ctx.fillText( card.value, card.x + 22, cardY + 105 ); // Sub ctx.fillStyle = "#7D86A3"; ctx.font = "15px Sans"; ctx.fillText( card.sub, card.x + 22, cardY + 130 ); // Progress drawBar( ctx, card.x + 22, cardY + 142, 205, 10, card.percent, card.color ); } // ============================== // BOTTOM SYSTEM INFO // ============================== roundRect( ctx, 75, 585, 1130, 100, 25 ); ctx.fillStyle = "#F7F8FE"; ctx.fill(); const bottom = [ { x: 120, title: "NODE", value: process.version }, { x: 390, title: "PLATFORM", value: os.platform() }, { x: 665, title: "ARCH", value: os.arch() }, { x: 940, title: "PID", value: String(process.pid) } ]; for (const item of bottom) { ctx.fillStyle = "#7B84A3"; ctx.font = "bold 15px Sans"; ctx.fillText( item.title, item.x, 620 ); ctx.fillStyle = "#17203F"; ctx.font = "bold 20px Sans"; ctx.fillText( item.value, item.x, 650 ); } // Dividers ctx.strokeStyle = "#E1E5F2"; ctx.lineWidth = 1; [345, 620, 895].forEach( (x) => { ctx.beginPath(); ctx.moveTo( x, 605 ); ctx.lineTo( x, 665 ); ctx.stroke(); } ); // ============================== // FOOTER // ============================== ctx.fillStyle = "#8991AC"; ctx.font = "14px Sans"; ctx.fillText( "REAL PROCESS MONITOR • GOAT BOT", 75, 695 ); drawStatusDot( ctx, 1045, 692, 7, "#35B85B" ); ctx.fillStyle = "#8991AC"; ctx.font = "14px Sans"; ctx.fillText( "All systems operational", 1065, 697 ); // ============================== // SAVE IMAGE // ============================== const cacheDir = path.join( __dirname, "cache" ); await fs.ensureDir( cacheDir ); const imagePath = path.join( cacheDir, "up2_" + Date.now() + ".png" ); await fs.writeFile( imagePath, canvas.toBuffer("image/png") ); // ============================== // SEND // ============================== return api.sendMessage( { body: "╭───〔 REAL BOT STATUS 〕───╮\n" + "│ 🟢 Status : ONLINE\n" + "│ ⏱️ Uptime : " + formatUptime(uptime) + "\n" + "│ 🧠 CPU : " + cpu.toFixed(1) + "%\n" + "│ 💾 Memory : " + memory.percent.toFixed(1) + "%\n" + "│ ⚙️ Core : " + cores + "\n" + "│ 💿 Disk : " + disk.percent.toFixed(1) + "%\n" + "╰──────────────────────────╯", attachment: fs.createReadStream( imagePath ) }, event.threadID, async () => { try { await fs.remove( imagePath ); } catch (e) {} }, event.messageID ); } catch (error) { console.error( "[UP2 ERROR]", error ); return api.sendMessage( "❌ Uptime Error\n\n" + "⚠️ " + ( error.message || "Unknown error" ), event.threadID, event.messageID ); } };