console queue should help ssh not crashing

This commit is contained in:
ChomeNS 2022-09-13 20:05:19 +07:00
parent 1ca72b1812
commit 329aebf40b

View file

@ -174,6 +174,7 @@ function main() {
};
dcmsg.queue = '';
consoleQueue = '';
bot.playersAddedPlayers = {};
bot.getplayerusername = {};
@ -210,6 +211,13 @@ function main() {
}
}, 1000);
consoleQueueInterval = setInterval(function() {
if (consoleQueue!='') {
console.log(bot.options.host + ': ' + consoleQueue.substring(0, 10000)/* message.toAnsi() + '\u001b[0m'*/);
consoleQueue = '';
}
}, 100);
console.log(`Connecting to: ${bot.options.host}:${bot.options.port}...`);
// fs.appendFileSync('./logs.txt', `\r\Connecting to: ${bot.options.host}:${bot.options.port}...\r\n`);
channel.send(`Connecting to: \`${bot.options.host}:${bot.options.port}\`...`);
@ -284,6 +292,9 @@ function main() {
bot.on('parsed_chat', async function(message, data) {
try {
if (previusMessage===message.toString()) return;
previusMessage = message.toString();
// prevents command set message and hi % exploit (it uses prismarine-chat)
const parsedMessage = JSON.parse(data.message);
if (parsedMessage.translate==='translation.test.invalid') return;
@ -295,10 +306,8 @@ function main() {
const cleanMessage = escapeMarkdown(message.toString());
discordMsg = /* '_ _ ' + */cleanMessage.replaceAll('@', '@\u200B').replaceAll('http', '[http]');// .replace(/[\r\n]/gm, '\n')
if (previusMessage===message.toString()) return;
previusMessage = message.toString();
consoleQueue += '\n' + message.toAnsi();
console.log(bot.options.host + ': ' + message.toAnsi()/* + '\u001b[0m'*/);
// fs.appendFileSync('./logs.txt', `${bot.options.host}: ${message.toMotd()}\r\n`);
// if (discordMsg)return channel.send(`${discordMsg.substring(0, 2000)}`)
if (message.toMotd().startsWith('§8[§r§eChomeNS §r§9Discord§r§8] §r§c')) return;