Merge #23

Merged
Sirherobrine23 merged 6 commits from main into stable 2021-02-02 03:25:55 +00:00
4 changed files with 1528 additions and 35 deletions
Showing only changes of commit 0f64e443e8 - Show all commits

View File

@@ -1,36 +1,41 @@
const si = require("systeminformation"); const si = require("systeminformation");
setInterval(() => { module.exports.current_cpu = undefined
si.cpu().then(data => {module.exports.cpu_speed = Math.trunc(data.speed)}) module.exports.ram_free = undefined
module.exports.ram_total = undefined
module.exports.cpu_speed = undefined
module.exports.bds_cpu = undefined
// module.exports.system = si
function init_1(){
si.cpu().then(data => {
module.exports.cpu_speed = Math.trunc(data.speed)
})
si.mem().then(data => { si.mem().then(data => {
module.exports.ram_free = Math.trunc(data.free / 1024 / 1024 / 1024); module.exports.ram_free = Math.trunc(data.free / 1024 / 1024 / 1024)
module.exports.ram_total = Math.trunc(data.total / 1024 / 1024 / 1024); module.exports.ram_total = Math.trunc(data.total / 1024 / 1024 / 1024)
}) })
si.currentLoad().then(data => { si.currentLoad().then(data => {
module.exports.current_cpu = Math.trunc(data.currentload) module.exports.current_cpu = Math.trunc(data.currentLoad)
}) })
}
}, 1000); function init_2(){
si.processes().then(data => { si.processes().then(data => {
const list = data.list const list = data.list
for (let pid in list) { for (let pid in list) {
var pids = list[pid].command var pids = list[pid].command
if (pids.includes("server")){ if (pids.includes("server.")){
module.exports.bds_cpu = Math.trunc(list[pid].pcpu) module.exports.bds_cpu = Math.trunc(list[pid].cpu)
} else { } else {
pid++ pid++
} }
} }
}) })
}
init_1()
init_2()
setInterval(() => { setInterval(() => {
si.processes().then(data => { init_1()
const list = data.list init_2()
for (let pid in list) {
var pids = list[pid].command
if (pids.includes("server")){
module.exports.bds_cpu = Math.trunc(list[pid].pcpu)
} else {
pid++
}
}
})
}, 3000); }, 3000);

View File

@@ -84,16 +84,15 @@ bot.command("list", (ctx) =>{
} }
}); });
bot.command("mcpe", (ctx) =>{ bot.command("mcpe", (ctx) =>{
// ctx.replyWithHTML(`<a href="https://storage.cloud.google.com/bds_mcpe_files/mcpe.apk">Minecraft for Android 1.16.201.01</a>`) ctx.replyWithMarkdown(`[Minecraft for Android 1.16.201.01](https://files.sh33.org/mcpe/latest.sonic)
const text = `[Minecraft for Android 1.16.201.01](https://files.sh33.org/mcpe/latest.sonic)
Iphone users are not privileged Iphone users are not privileged
` `)});
ctx.replyWithMarkdown(text)
});
bot.command("status", (ctx) =>{ bot.command("status", (ctx) =>{
const status = require("./system_monitor") const {bds_cpu, current_cpu, ram_total, ram_free} = require("./system_monitor")
const text = `Bds CPU usage: ${bds_cpu}%, Total CPU utilization: ${current_cpu}%\n\n\nTotal ram memory: ${ram_total} GB, Total free ram memory: ${ram_free} GB` const text = `Bds CPU usage: ${bds_cpu}%, Total CPU utilization: ${current_cpu}%
Total ram memory: ${ram_total} GB, Total free ram memory: ${ram_free} GB`
ctx.replyWithMarkdown(text); ctx.replyWithMarkdown(text);
}); });
bot.command("log", (ctx) => { bot.command("log", (ctx) => {

1493
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "bds_maneger_api", "name": "bds_maneger_api",
"version": "1.5.0", "version": "1.5.2",
"description": "scripts to manage minecraft bedrock server", "description": "scripts to manage minecraft bedrock server",
"private": false, "private": false,
"main": "index.js", "main": "index.js",