messagelogging

This commit is contained in:
ChomeNS 2022-10-19 19:22:26 +07:00
parent cc1dd74801
commit 3780245861

View file

@ -105,8 +105,6 @@ function botThings() {
hideErrors: true, hideErrors: true,
}; };
bot._client = mc.createClient(bot.options); bot._client = mc.createClient(bot.options);
bot.uuid = bot._client.uuid;
bot.username = bot._client.username;
bot.version = bot._client.version; bot.version = bot._client.version;
bot.queue = []; bot.queue = [];
bot.write = (name, data) => bot._client.write(name, data); bot.write = (name, data) => bot._client.write(name, data);
@ -176,6 +174,8 @@ function main() {
dcmsg.queue = ''; dcmsg.queue = '';
consoleQueue = []; consoleQueue = [];
bot.messageLoggingEnabled = true;
bot.playersAddedPlayers = {}; bot.playersAddedPlayers = {};
bot.getplayerusername = {}; bot.getplayerusername = {};
@ -212,6 +212,7 @@ function main() {
}, 1000); }, 1000);
consoleQueueInterval = setInterval(function() { consoleQueueInterval = setInterval(function() {
if (!bot.messageLoggingEnabled) return;
if (consoleQueue.length > 50) consoleQueue = []; if (consoleQueue.length > 50) consoleQueue = [];
if (consoleQueue[0] || consoleQueue[0]==='') { if (consoleQueue[0] || consoleQueue[0]==='') {
console.log(bot.options.host + ': ' + consoleQueue[0].substring(0, 10000)/* message.toAnsi() + '\u001b[0m'*/); console.log(bot.options.host + ': ' + consoleQueue[0].substring(0, 10000)/* message.toAnsi() + '\u001b[0m'*/);
@ -224,6 +225,8 @@ function main() {
channel.send(`Connecting to: \`${bot.options.host}:${bot.options.port}\`...`); channel.send(`Connecting to: \`${bot.options.host}:${bot.options.port}\`...`);
bot._client.on('login', async function(data) { bot._client.on('login', async function(data) {
bot.entityId = data.entityId; bot.entityId = data.entityId;
bot.uuid = bot._client.uuid;
bot.username = bot._client.username;
const chatMessage = require('prismarine-chat')(bot.version); const chatMessage = require('prismarine-chat')(bot.version);
const mcData = require('minecraft-data')(bot.version); const mcData = require('minecraft-data')(bot.version);
console.log(`Successfully logged in to: ${bot.options.host}:${bot.options.port}`); console.log(`Successfully logged in to: ${bot.options.host}:${bot.options.port}`);
@ -476,6 +479,14 @@ dcclient.on('ready', async () => {
consoleQueue = []; consoleQueue = [];
return; return;
} }
if (line==='.messagelogging on') {
bot.messageLoggingEnabled = true;
return;
}
if (line==='.messagelogging off') {
bot.messageLoggingEnabled = false;
return;
}
if (line==='.kill') process.exit(); if (line==='.kill') process.exit();
// if (line.startsWith("."))return console.log('command not found') // if (line.startsWith("."))return console.log('command not found')
if (line.startsWith('.')) return bot.command_handler.run('Console', '§a§lConsole§r', '*' + line.substring(1), 'c0ns0le-uuid'); if (line.startsWith('.')) return bot.command_handler.run('Console', '§a§lConsole§r', '*' + line.substring(1), 'c0ns0le-uuid');