remove hi %

This commit is contained in:
ChomeNS 2022-12-03 14:05:23 +07:00
parent d6a8133c2b
commit 0fdc93574a

View file

@ -6,13 +6,9 @@
* @param {object} bot bot * @param {object} bot bot
*/ */
function chatPacketListener (packet, ChatMessage, bot) { function chatPacketListener (packet, ChatMessage, bot) {
// try catch prevents hi % exploit (it uses prismarine-chat) // try catch prevents json parse error (which prob never happens but still..)
// and try catch also prevents json parse error
try { try {
const parsedMessage = JSON.parse(packet.message) const parsedMessage = JSON.parse(packet.message)
if (parsedMessage.translate === 'translation.test.invalid' ||
parsedMessage.translate === 'translation.test.invalid2') return
// down here it prevents command set message // down here it prevents command set message
// for ayunboom cuz its 1.17.1 // for ayunboom cuz its 1.17.1
@ -27,9 +23,7 @@ function chatPacketListener (packet, ChatMessage, bot) {
const message = ChatMessage.fromNotch(packet.message) const message = ChatMessage.fromNotch(packet.message)
bot.emit('parsed_chat', message, packet) bot.emit('parsed_chat', message, packet)
} catch (e) { } catch (e) {}
}
}; };
/** /**
@ -40,11 +34,7 @@ function chatPacketListener (packet, ChatMessage, bot) {
*/ */
function parsePlayerMessages (message, packet, bot) { function parsePlayerMessages (message, packet, bot) {
try { try {
// prevent braille cuz it CRASHES THE ENTIRE LAPTOP // here is all the player message parsing thing
// but sometimes this may not work
if (message.toString().includes('⣿')) return
// then here is all the player message parsing thing
const raw = message.toMotd().substring(0, 32767) const raw = message.toMotd().substring(0, 32767)
if (raw.match(/.* .*: .*/g)) { if (raw.match(/.* .*: .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '') const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '')