Merge #23

Merged
Sirherobrine23 merged 6 commits from main into stable 2021-02-02 03:25:55 +00:00
5 changed files with 56 additions and 93 deletions

View File

@ -1,12 +0,0 @@
var qr = require('qr-image');
var express = require('express');
var app = express();
app.get('/', function(req, res) {
var code = qr.image(`list: ${Math.random()}`, { type: 'svg' });
res.type('svg');
code.pipe(res);
});
app.listen(3000);

View File

@ -1,41 +1,41 @@
const bds_monitor = process.env.BDS_MONI.includes("true")
if (bds_monitor){
const si = require("systeminformation");
setInterval(() => {
// si.cpu().then(data => {module.exports.cpu_speed = Math.trunc(data.speed)})
const si = require("systeminformation");
module.exports.current_cpu = undefined
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 => {
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_free = Math.trunc(data.free / 1024 / 1024 / 1024)
module.exports.ram_total = Math.trunc(data.total / 1024 / 1024 / 1024)
})
si.currentLoad().then(data => {
module.exports.current_cpu = Math.trunc(data.currentload)
module.exports.current_cpu = Math.trunc(data.currentLoad)
})
}, 1000);
si.processes().then(data => {
const list = data.list
for (let pid in list) {
var pids = list[pid].command
if (pids.includes("bedrock_server")){
module.exports.bds_cpu = Math.trunc(list[pid].pcpu)
} else {
pid++
}
}
})
setInterval(() => {
si.processes().then(data => {
const list = data.list
for (let pid in list) {
var pids = list[pid].command
if (pids.includes("bedrock_server")){
module.exports.bds_cpu = Math.trunc(list[pid].pcpu)
} else {
pid++
}
}
})
}, 3000);
}else {
console.warn(`the use of cpu is disabled, for more information, visit https://docs.srherobrine23.com/enable_bds_requests.html`)
}
function init_2(){
si.processes().then(data => {
const list = data.list
for (let pid in list) {
var pids = list[pid].command
if (pids.includes("server.")){
module.exports.bds_cpu = Math.trunc(list[pid].cpu)
} else {
pid++
}
}
})
}
init_1()
init_2()
setInterval(() => {
init_1()
init_2()
}, 3000);

View File

@ -11,6 +11,8 @@ Commands:
/log
/command
/list
/mcpe
/status
The messages are re-transmitted to the minecraft chat if it is already connected:
Message Control: `
ctx.reply(amenssagem)
@ -82,44 +84,17 @@ bot.command("list", (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>`)
const text = `[Minecraft for Android 1.16.201.01](https://storage.googleapis.com/bds_mcpe_files/0.16.201.01.apk)
ctx.replyWithMarkdown(`[Minecraft for Android 1.16.201.01](https://files.sh33.org/mcpe/latest.sonic)
Iphone users are not privileged
`
ctx.replyWithMarkdown(text)
`)});
bot.command("status", (ctx) =>{
const {bds_cpu, current_cpu, ram_total, ram_free} = require("./system_monitor")
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);
});
// bot.command("status", (ctx) =>{
// const si = require("systeminformation");
// // si.cpu().then(data => {module.exports.cpu_speed = Math.trunc(data.speed)})
// si.mem().then(data => {
// global.ram_free = Math.trunc(data.free / 1024 / 1024 / 1024);
// global.ram_total = Math.trunc(data.total / 1024 / 1024 / 1024);
// si.currentLoad().then(data => {
// global.current_cpu = Math.trunc(data.currentload)
// si.processes().then(data => {
// const list = data.list
// for (let pid in list) {
// var pids = list[pid].command
// if (pids.includes("bedrock_server")){global.bds_cpu = Math.trunc(list[pid].pcpu)} else if (pids.includes("server.jar")){global.bds_cpu = Math.trunc(list[pid].pcpu)} else {pid++}
// }
// si.processes().then(data => {
// const list = data.list
// for (let pid in list) {
// var pids = list[pid].command
// if (pids.includes("bedrock_server")){global.bds_cpu = Math.trunc(list[pid].pcpu)} else {pid++}
// }
// 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`
// ctx.replyWithMarkdown(text);
// delete(bds_cpu);
// delete(current_cpu);
// delete(ram_total);
// delete(ram_free);
// })
// })
// })
// })
// });
bot.command("log", (ctx) => {
const file_log_path = require("../index").log_file;
const fs = require("fs")

28
package-lock.json generated
View File

@ -1,11 +1,11 @@
{
"name": "bds_maneger_api",
"version": "1.5.0",
"version": "1.5.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.5.0",
"version": "1.5.2",
"license": "AGPL-3.0-or-later",
"dependencies": {
"adm-zip": "^0.5.1",
@ -970,9 +970,9 @@
}
},
"node_modules/open": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/open/-/open-7.3.1.tgz",
"integrity": "sha512-f2wt9DCBKKjlFbjzGb8MOAW8LH8F0mrs1zc7KTjAJ9PZNQbfenzWbNP1VZJvw6ICMG9r14Ah6yfwPn7T7i646A==",
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-7.4.0.tgz",
"integrity": "sha512-PGoBCX/lclIWlpS/R2PQuIR4NJoXh6X5AwVzE7WXnWRGvHg7+4TBCgsujUgiPpm0K1y4qvQeWnCWVTpTKZBtvA==",
"dependencies": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"
@ -1304,9 +1304,9 @@
}
},
"node_modules/systeminformation": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.0.6.tgz",
"integrity": "sha512-sX8I5SPunheS99VYBk1UGzavNMBGTizccaKcYo6TrjPaHF98iFeirexNX99zyGujlNWTVCHiVxzoNdix77hkVw==",
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.0.8.tgz",
"integrity": "sha512-K2AzDnKx0ujD11EenI3VPegNM6ygGlcxj52SsaJ6B8JdYBgUS6HX8WrOY7dfqGvSkwqXNA/YkcWcf5EeFN5wng==",
"os": [
"darwin",
"linux",
@ -2248,9 +2248,9 @@
}
},
"open": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/open/-/open-7.3.1.tgz",
"integrity": "sha512-f2wt9DCBKKjlFbjzGb8MOAW8LH8F0mrs1zc7KTjAJ9PZNQbfenzWbNP1VZJvw6ICMG9r14Ah6yfwPn7T7i646A==",
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-7.4.0.tgz",
"integrity": "sha512-PGoBCX/lclIWlpS/R2PQuIR4NJoXh6X5AwVzE7WXnWRGvHg7+4TBCgsujUgiPpm0K1y4qvQeWnCWVTpTKZBtvA==",
"requires": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"
@ -2500,9 +2500,9 @@
}
},
"systeminformation": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.0.6.tgz",
"integrity": "sha512-sX8I5SPunheS99VYBk1UGzavNMBGTizccaKcYo6TrjPaHF98iFeirexNX99zyGujlNWTVCHiVxzoNdix77hkVw=="
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.0.8.tgz",
"integrity": "sha512-K2AzDnKx0ujD11EenI3VPegNM6ygGlcxj52SsaJ6B8JdYBgUS6HX8WrOY7dfqGvSkwqXNA/YkcWcf5EeFN5wng=="
},
"telegraf": {
"version": "4.0.2",

View File

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