mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
hope this fix the multiple thingy ploblem
This commit is contained in:
parent
820f7ad576
commit
3f10357d94
3 changed files with 23 additions and 6 deletions
1
bot.js
1
bot.js
|
@ -49,6 +49,7 @@ async function createBot(server, config, getBots, dcclient) {
|
|||
bot.removeAllListeners();
|
||||
bot._client.end();
|
||||
bot._client.removeAllListeners();
|
||||
process.removeAllListeners();
|
||||
};
|
||||
bot.visibility = false;
|
||||
bot.getBots = getBots;
|
||||
|
|
|
@ -7,16 +7,25 @@ const {chatPacketListener, parsePlayerMessages} = require('../util/chat');
|
|||
|
||||
function inject(bot) {
|
||||
bot.chatQueue = [];
|
||||
let chatQueueSplitted;
|
||||
|
||||
const chatQueue = setInterval(function() {
|
||||
try {
|
||||
if (bot.chatQueue[0] || bot.chatQueue[0] === '') {
|
||||
try {
|
||||
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||
bot.chatQueue.shift();
|
||||
return;
|
||||
};
|
||||
bot.write('chat', {message: bot.chatQueue[0].substring(0, 256)});
|
||||
chatQueueSplitted = bot.chatQueue[0].match(/.{0,224}/g);
|
||||
chatQueueSplitted.pop();
|
||||
}
|
||||
}, 20);
|
||||
|
||||
const sendChatQueue = setInterval(function() {
|
||||
try {
|
||||
if (chatQueueSplitted) {
|
||||
try {
|
||||
bot.write('chat', {message: chatQueueSplitted[0]});
|
||||
chatQueueSplitted.shift();
|
||||
bot.chatQueue.shift();
|
||||
} catch (e) {
|
||||
bot.console.error(e);
|
||||
|
@ -33,6 +42,7 @@ function inject(bot) {
|
|||
|
||||
bot.once('end', () => {
|
||||
clearInterval(chatQueue);
|
||||
clearInterval(sendChatQueue);
|
||||
});
|
||||
|
||||
let previousMessage;
|
||||
|
|
|
@ -50,17 +50,23 @@ function inject(bot, dcclient, config) {
|
|||
|
||||
targetClient.on('end', () => {
|
||||
targetClient.end();
|
||||
targetClient.removeAllListeners();
|
||||
client.removeAllListeners();
|
||||
endedTarget = true;
|
||||
});
|
||||
|
||||
client.on('end', function() {
|
||||
endedClient = true;
|
||||
targetClient.end();
|
||||
targetClient.removeAllListeners();
|
||||
client.removeAllListeners();
|
||||
bot.console.info(`[Proxy] ${client.username} ended`);
|
||||
});
|
||||
|
||||
client.on('error', function() {
|
||||
endedClient = true;
|
||||
targetClient.removeAllListeners();
|
||||
client.removeAllListeners();
|
||||
bot.console.info(`[Proxy] ${client.username} got error`);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue