mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2025-02-17 06:40:17 -05:00
console queue should help ssh not crashing
This commit is contained in:
parent
1ca72b1812
commit
329aebf40b
1 changed files with 12 additions and 3 deletions
15
index.js
15
index.js
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue