Rename VoolEagler58 and add /etc/os-release check

This commit is contained in:
7cc5c4f330d47060 2024-07-16 11:24:35 -04:00
parent ae432da277
commit 099a806f48

View file

@ -3,7 +3,7 @@ const cp = require('child_process')
const settings = require('../../settings.json') const settings = require('../../settings.json')
const timeformat = require('../../util/timeformat.js') const timeformat = require('../../util/timeformat.js')
const fs=require("fs") const fs=require("fs")
const VoolEagler58 = function (text, value, color) { const gr = function (text, value, color) {
if (!color) color = 'white' if (!color) color = 'white'
return JSON.stringify({ return JSON.stringify({
translate: '%s: %s', translate: '%s: %s',
@ -45,41 +45,42 @@ const os2 = function (o2) {
return o2 return o2
} }
} }
// b.tellraw(sender,VoolEagler58("Example",example)) // b.tellraw(sender,gr("Example",example))
module.exports = { module.exports = {
execute: function (c) { execute: function (c) {
c.reply(VoolEagler58('Operating system', os2(process.platform))) c.reply(gr('Operating system', os2(process.platform)))
c.reply(VoolEagler58('CPU', os.cpus()[0].model)) c.reply(gr('CPU', os.cpus()[0].model))
c.reply(VoolEagler58('Architecture', os.machine())) c.reply(gr('Architecture', os.machine()))
c.reply(VoolEagler58('Username', os.userInfo().username)) c.reply(gr('Username', os.userInfo().username))
c.reply(VoolEagler58('Bot uptime', timeformat(process.uptime() * 1000))) c.reply(gr('Bot uptime', timeformat(process.uptime() * 1000)))
c.reply(VoolEagler58('System uptime', timeformat(os.uptime() * 1000))) c.reply(gr('System uptime', timeformat(os.uptime() * 1000)))
// b.tellraw(sender,VoolEagler58('System memory (total)',Math.floor(os.totalmem()/1000000)+'MB')); c.reply(gr('Node.js version', process.version))
c.reply(VoolEagler58('Node.js version', process.version))
if (process.platform == 'linux' || process.platform == 'freebsd') { if (process.platform == 'linux' || process.platform == 'freebsd') {
// const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0]; try{
/* /etc/os-release parser */ const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n");
const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n"); let osrelease2={};
let osrelease2={}; for(const i in osrelease){
for(const i in osrelease){ if(!osrelease[i].includes("=")) continue;
if(!osrelease[i].includes("=")) continue; let osr_value=osrelease[i].split("=")[1];
let osr_value=osrelease[i].split("=")[1]; if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)};
if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)}; osrelease2[osrelease[i].split("=")[0]]=osr_value;
osrelease2[osrelease[i].split("=")[0]]=osr_value; }
}
if(osrelease2.PRETTY_NAME){ if(osrelease2.PRETTY_NAME){
c.reply(VoolEagler58('Linux release', osrelease2.PRETTY_NAME, 'dark_green')) c.reply(gr('Linux release', osrelease2.PRETTY_NAME, 'dark_green'))
}
} catch(e){
c.reply('{"text":"/etc/os-release does not exist. Information may be limited."}')
} }
} else if (process.platform == 'android') { } else if (process.platform == 'android') {
// const android_sdk=+cp.execSync("getprop ro.build.version.sdk").toString("UTF-8").split("\n")[0];
const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0] const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
c.reply(VoolEagler58('Android version', android_version, 'green')) c.reply(gr('Android version', android_version, 'green'))
c.reply(VoolEagler58('Device model', cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0], 'green')) const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0];
c.reply(VoolEagler58('Device brand', cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0], 'green')) const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0];
c.reply(gr('Device model', dBrand+dModel, 'green'))
} }
c.reply(VoolEagler58('Bot name', settings.name, 'yellow')) c.reply(gr('Bot name', settings.name, 'yellow'))
c.reply(VoolEagler58('Bot version', settings.version, 'yellow')) c.reply(gr('Bot version', settings.version, 'yellow'))
}, },
desc: 'Get system/bot info (ported from V9). Not complete.', desc: 'Get system/bot info (ported from V9). Not complete.',
usage: '' usage: ''