chat queue broke everything, answer revealed.

This commit is contained in:
ChomeNS 2022-11-18 08:34:18 +07:00
parent fb9eae6d52
commit b0cd12c717

View file

@ -7,24 +7,15 @@ const {chatPacketListener, parsePlayerMessages} = require('../util/chat');
function inject(bot) {
bot.chatQueue = [];
let chatQueueSplitted;
const chatQueue = setInterval(function() {
if (bot.chatQueue[0] || bot.chatQueue[0] === '') {
if (containsIllegalCharacters(bot.chatQueue[0])) {
bot.chatQueue.shift();
return;
};
chatQueueSplitted = bot.chatQueue[0].match(/.{0,224}/g);
chatQueueSplitted.pop();
}
}, 20);
const sendChatQueue = setInterval(function() {
if (chatQueueSplitted) {
try {
bot.write('chat', {message: chatQueueSplitted[0]});
chatQueueSplitted.shift();
if (containsIllegalCharacters(bot.chatQueue[0])) {
bot.chatQueue.shift();
return;
};
bot.write('chat', {message: bot.chatQueue[0]});
bot.chatQueue.shift();
} catch (e) {
bot.console.error(e);
@ -38,7 +29,6 @@ function inject(bot) {
bot.once('end', () => {
clearInterval(chatQueue);
clearInterval(sendChatQueue);
});
let previousMessage;