remove previousMessage check cuz USELESS

This commit is contained in:
ChomeNS 2022-11-21 17:38:34 +07:00
parent 13c7c5fd1e
commit 9fc6f69140
2 changed files with 2 additions and 8 deletions

View file

@ -31,10 +31,9 @@ function inject(bot) {
clearInterval(chatQueue);
});
let previousMessage;
const ChatMessage = require('prismarine-chat')(bot.version);
bot._client.on('chat', (packet) => chatPacketListener(packet, ChatMessage, previousMessage, bot));
bot._client.on('chat', (packet) => chatPacketListener(packet, ChatMessage, bot));
bot.on('parsed_chat', (message, packet) => parsePlayerMessages(message, packet, bot));
}

View file

@ -3,10 +3,9 @@
* for the chat packet listener (in util cuz proxy + bot)
* @param {object} packet chat packet
* @param {object} ChatMessage basically just require prismarine-chat
* @param {string} previousMessage previous message.
* @param {object} bot bot
*/
function chatPacketListener(packet, ChatMessage, previousMessage, bot) {
function chatPacketListener(packet, ChatMessage, bot) {
// try catch prevents hi % exploit (it uses prismarine-chat)
// and try catch also prevents json parse error
try {
@ -27,10 +26,6 @@ function chatPacketListener(packet, ChatMessage, previousMessage, bot) {
const message = ChatMessage.fromNotch(packet.message);
// before emitting, prevent spam first!!!
if (previousMessage === message.toString()) return;
previousMessage = message.toString();
bot.emit('parsed_chat', message, packet);
} catch (e) {
return;