mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2025-02-17 06:40:17 -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) {
|
function inject(bot) {
|
||||||
bot.chatQueue = [];
|
bot.chatQueue = [];
|
||||||
let chatQueueSplitted;
|
|
||||||
|
|
||||||
const chatQueue = setInterval(function() {
|
const chatQueue = setInterval(function() {
|
||||||
if (bot.chatQueue[0] || bot.chatQueue[0] === '') {
|
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 {
|
try {
|
||||||
bot.write('chat', {message: chatQueueSplitted[0]});
|
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||||
chatQueueSplitted.shift();
|
bot.chatQueue.shift();
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
bot.write('chat', {message: bot.chatQueue[0]});
|
||||||
bot.chatQueue.shift();
|
bot.chatQueue.shift();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e);
|
||||||
|
@ -38,7 +29,6 @@ function inject(bot) {
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(chatQueue);
|
clearInterval(chatQueue);
|
||||||
clearInterval(sendChatQueue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let previousMessage;
|
let previousMessage;
|
||||||
|
|
Loading…
Reference in a new issue