mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
chat queue broke everything, answer revealed.
This commit is contained in:
parent
fb9eae6d52
commit
b0cd12c717
1 changed files with 5 additions and 15 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue