// code from goatstore // api: https://store.agi.bd module.exports.config = { name: "up2", version: "4.0.0", author: "Zihad • Real Uptime", aliases: ["upt", "up2"], role: 0, category: "system", guide: "{pn}" }; const { createCanvas } = require("canvas"); const fs = require("fs-extra"); const os = require("os"); const path = require("path"); module.exports.onStart = async function ({ api, event }) { try { // ========================= // REAL BOT PROCESS UPTIME // ========================= function getBotUptime() { return Math.floor(process.uptime()); } function 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" ); } // ========================= // MEMORY // ========================= function getMemory() { const total = os.totalmem(); const free = os.freemem(); const used = total - free; return { total, free, used, percent: total > 0 ? (used / total) * 100 : 0 }; } // ========================= // CPU // ========================= function 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 += t.idle; total += t.user + t.nice + t.sys + t.idle + t.irq; } if (!total) return 0; return Math.max( 0, Math.min( 100, 100 - (idle / total) * 100 ) ); } catch (e) { return 0; } } // ========================= // DISK // ========================= function 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 }; } } function bytes(bytes) { if (!bytes || bytes <= 0) { return "0 MB"; } const units = [ "B", "KB", "MB", "GB", "TB" ]; let i = 0; let value = bytes; while ( value >= 1024 && i < units.length - 1 ) { value /= 1024; i++; } return ( value.toFixed(i === 0 ? 0 : 1) + " " + units[i] ); } // ========================= // DRAW FUNCTIONS // ========================= function 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(); } function bubble( ctx, x, y, r, color, alpha = 1 ) { ctx.save(); ctx.globalAlpha = alpha; ctx.fillStyle = color; ctx.beginPath(); ctx.arc( x, y, r, 0, Math.PI * 2 ); ctx.fill(); ctx.restore(); } function sparkle( ctx, x, y, size, color ) { ctx.save(); ctx.fillStyle = color; ctx.beginPath(); ctx.moveTo( x, y - size ); ctx.lineTo( x + size * 0.25, y - size * 0.25 ); ctx.lineTo( x + size, y ); ctx.lineTo( x + size * 0.25, y + size * 0.25 ); ctx.lineTo( x, y + size ); ctx.lineTo( x - size * 0.25, y + size * 0.25 ); ctx.lineTo( x - size, y ); ctx.lineTo( x - size * 0.25, y - size * 0.25 ); ctx.closePath(); ctx.fill(); ctx.restore(); } function cloud( ctx, x, y, scale = 1 ) { ctx.save(); ctx.globalAlpha = 0.65; ctx.fillStyle = "#FFFFFF"; ctx.beginPath(); ctx.arc( x, y + 22 * scale, 30 * scale, 0, Math.PI * 2 ); ctx.arc( x + 35 * scale, y, 40 * scale, 0, Math.PI * 2 ); ctx.arc( x + 76 * scale, y + 20 * scale, 31 * scale, 0, Math.PI * 2 ); ctx.moveTo( x - 30 * scale, y + 22 * scale ); ctx.quadraticCurveTo( x + 40 * scale, y + 58 * scale, x + 105 * scale, y + 23 * scale ); ctx.lineTo( x + 105 * scale, y + 45 * scale ); ctx.lineTo( x - 30 * scale, y + 45 * scale ); ctx.closePath(); ctx.fill(); ctx.restore(); } function progress( ctx, x, y, w, h, value ) { value = Math.max( 0, Math.min(100, value || 0) ); roundRect( ctx, x, y, w, h, h / 2 ); ctx.fillStyle = "#E9E4F1"; ctx.fill(); if (value > 0) { const pw = Math.max( h, (w * value) / 100 ); roundRect( ctx, x, y, Math.min(w, pw), h, h / 2 ); const g = ctx.createLinearGradient( x, y, x + w, y ); g.addColorStop( 0, "#987DE5" ); g.addColorStop( 1, "#C59BEF" ); ctx.fillStyle = g; ctx.fill(); } } // ========================= // GET REAL DATA // ========================= const uptime = getBotUptime(); 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 bg = ctx.createLinearGradient( 0, 0, width, height ); bg.addColorStop( 0, "#E9F6FF" ); bg.addColorStop( 0.5, "#F1ECFF" ); bg.addColorStop( 1, "#FFF0F6" ); ctx.fillStyle = bg; ctx.fillRect( 0, 0, width, height ); // Decorations cloud(ctx, 60, 70, 1); cloud(ctx, 1010, 70, 1.2); cloud(ctx, 1110, 280, 0.55); bubble( ctx, 110, 310, 55, "#D8CBFF", 0.25 ); bubble( ctx, 1180, 510, 70, "#B8DFF7", 0.25 ); sparkle( ctx, 1050, 180, 10, "#C3B4F0" ); sparkle( ctx, 180, 180, 7, "#A8D5F0" ); sparkle( ctx, 1120, 330, 6, "#E2A9C2" ); // Main panel ctx.save(); ctx.shadowColor = "rgba(90,70,120,0.18)"; ctx.shadowBlur = 40; ctx.shadowOffsetY = 15; roundRect( ctx, 55, 45, 1170, 665, 48 ); const panel = ctx.createLinearGradient( 55, 45, 1225, 710 ); panel.addColorStop( 0, "rgba(255,255,255,0.96)" ); panel.addColorStop( 1, "rgba(255,249,253,0.94)" ); ctx.fillStyle = panel; ctx.fill(); ctx.restore(); // ========================= // HEADER // ========================= ctx.fillStyle = "#443A5B"; ctx.font = "bold 42px Sans"; ctx.fillText( "UPTIME", 105, 115 ); ctx.fillStyle = "#9389A6"; ctx.font = "18px Sans"; ctx.fillText( "Real-time bot process information", 108, 145 ); bubble( ctx, 1075, 105, 9, "#6FD59A" ); ctx.fillStyle = "#6B6280"; ctx.font = "bold 14px Sans"; ctx.fillText( "ONLINE", 1095, 110 ); // ========================= // REAL UPTIME BOX // ========================= ctx.save(); ctx.shadowColor = "rgba(114,96,155,0.13)"; ctx.shadowBlur = 25; ctx.shadowOffsetY = 8; roundRect( ctx, 105, 175, 1070, 150, 32 ); const hero = ctx.createLinearGradient( 105, 175, 1175, 325 ); hero.addColorStop( 0, "#F5F0FF" ); hero.addColorStop( 1, "#FCEFF7" ); ctx.fillStyle = hero; ctx.fill(); ctx.restore(); ctx.fillStyle = "#9487B4"; ctx.font = "bold 17px Sans"; ctx.fillText( "REAL BOT UPTIME", 140, 215 ); ctx.fillStyle = "#403653"; ctx.font = "bold 52px Sans"; ctx.fillText( formatUptime(uptime), 140, 275 ); ctx.fillStyle = "#9B91A9"; ctx.font = "15px Sans"; ctx.fillText( "Node.js process.uptime()", 142, 300 ); // ========================= // CARDS // ========================= const cards = [ { x: 105, title: "CPU", value: cpu.toFixed(1) + "%", sub: "Processor usage", percent: cpu }, { x: 385, title: "MEMORY", value: memory.percent.toFixed(1) + "%", sub: bytes(memory.used) + " / " + bytes(memory.total), percent: memory.percent }, { x: 665, title: "CORE", value: String(cores), sub: "CPU cores", percent: Math.min( 100, cores * 10 ) }, { x: 945, title: "DISK", value: disk.percent.toFixed(1) + "%", sub: bytes(disk.used) + " / " + bytes(disk.total), percent: disk.percent } ]; for (const card of cards) { const y = 350; ctx.save(); ctx.shadowColor = "rgba(100,85,130,0.10)"; ctx.shadowBlur = 18; ctx.shadowOffsetY = 6; roundRect( ctx, card.x, y, 250, 145, 25 ); ctx.fillStyle = "rgba(255,255,255,0.94)"; ctx.fill(); ctx.restore(); ctx.fillStyle = "#9186A5"; ctx.font = "bold 14px Sans"; ctx.fillText( card.title, card.x + 22, y + 32 ); ctx.fillStyle = "#443A5B"; ctx.font = "bold 30px Sans"; ctx.fillText( card.value, card.x + 22, y + 70 ); ctx.fillStyle = "#A19AAD"; ctx.font = "12px Sans"; ctx.fillText( card.sub, card.x + 22, y + 94 ); progress( ctx, card.x + 22, y + 112, 205, 9, card.percent ); } // ========================= // FOOTER // ========================= ctx.save(); roundRect( ctx, 105, 525, 1070, 130, 28 ); ctx.fillStyle = "rgba(248,245,252,0.95)"; ctx.fill(); ctx.restore(); const info = [ [ "NODE", process.version, 135 ], [ "PLATFORM", os.platform(), 390 ], [ "ARCH", os.arch(), 650 ], [ "PID", String(process.pid), 930 ] ]; for (const item of info) { ctx.fillStyle = "#9186A5"; ctx.font = "bold 13px Sans"; ctx.fillText( item[0], item[2], 560 ); ctx.fillStyle = "#4B425C"; ctx.font = "bold 17px Sans"; ctx.fillText( item[1], item[2], 590 ); } ctx.fillStyle = "#AAA1B5"; ctx.font = "12px Sans"; ctx.fillText( "REAL PROCESS MONITOR • GOAT BOT", 105, 685 ); // ========================= // SAVE // ========================= 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 (_) {} }, event.messageID ); } catch (error) { console.error( "[UP2 REAL ERROR]", error ); return api.sendMessage( "❌ Uptime Error\n\n" + "⚠️ " + (error.message || "Unknown error"), event.threadID, event.messageID ); } };