Push some owner-only commands
This commit is contained in:
parent
e95671d3be
commit
bcddfb06ba
4 changed files with 95 additions and 49 deletions
|
@ -1,38 +1,5 @@
|
|||
const Config = require('../props/config.json');
|
||||
const os = require('os');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
|
||||
function formatUptime(uptime) {
|
||||
const hours = Math.floor(uptime / 3600);
|
||||
const minutes = Math.floor((uptime % 3600) / 60);
|
||||
const seconds = Math.floor(uptime % 60);
|
||||
return `${hours}h ${minutes}m ${seconds}s`;
|
||||
}
|
||||
|
||||
function getSystemInfo() {
|
||||
const platform = os.platform();
|
||||
const release = os.release();
|
||||
const arch = os.arch();
|
||||
const cpuModel = os.cpus()[0].model;
|
||||
const cpuCores = os.cpus().length;
|
||||
const totalMemory = (os.totalmem() / (1024 ** 3)).toFixed(2) + ' GB';
|
||||
const freeMemory = (os.freemem() / (1024 ** 3)).toFixed(2) + ' GB';
|
||||
const loadAverage = os.loadavg().map(avg => avg.toFixed(2)).join(', ');
|
||||
const uptime = formatUptime(os.uptime());
|
||||
const nodeVersion = process.version;
|
||||
|
||||
return `*Server Stats*\n\n` +
|
||||
`*OS:* \`${platform} ${release}\`\n` +
|
||||
`*Arch:* \`${arch}\`\n` +
|
||||
`*Node.js Version:* \`${nodeVersion}\`\n` +
|
||||
`*CPU:* \`${cpuModel}\`\n` +
|
||||
`*CPU Cores:* \`${cpuCores} cores\`\n` +
|
||||
`*RAM:* \`${freeMemory} / ${totalMemory}\`\n` +
|
||||
`*Load Average:* \`${loadAverage}\`\n` +
|
||||
`*Uptime:* \`${uptime}\`\n\n`;
|
||||
}
|
||||
|
||||
// Função para obter informações do usuário
|
||||
async function getUserInfo(ctx) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
let userInfoTemplate = Strings.userInfo;
|
||||
|
@ -55,7 +22,6 @@ async function getUserInfo(ctx) {
|
|||
return userInfoTemplate;
|
||||
}
|
||||
|
||||
// Função para obter informações do chat
|
||||
async function getChatInfo(ctx) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
if (ctx.chat.type === 'group' || ctx.chat.type === 'supergroup') {
|
||||
|
@ -84,21 +50,6 @@ async function getChatInfo(ctx) {
|
|||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('stats', (ctx) => {
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
const machineStats = getSystemInfo();
|
||||
ctx.reply(
|
||||
machineStats, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
}
|
||||
);
|
||||
} else {
|
||||
ctx.reply(Strings.noPermission);
|
||||
}
|
||||
});
|
||||
|
||||
bot.command('chatinfo', async (ctx) => {
|
||||
const chatInfo = await getChatInfo(ctx);
|
||||
ctx.reply(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue