From 99e28d5360341c0972b0ff0e5be6b6ad2906e323 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Tue, 25 Oct 2022 12:23:05 +0700 Subject: [PATCH] fix chat on kitsune + filter braille --- index.js | 2 ++ plugins/chat.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7708640..be9d383 100644 --- a/index.js +++ b/index.js @@ -312,6 +312,8 @@ function main() { if (parsedMessage.extra!==undefined) { if (parsedMessage.extra[0].text==='Command set: ') return; } + // prevent braille cuz it CRASHES THE ENTIRE LAPTOP + if (message.toString().includes('⣿')) return; const cleanMessage = escapeMarkdown(message.toAnsi(), true); discordMsg = /* '_ _ ' + */cleanMessage.replaceAll('@', '@\u200b\u200b\u200b\u200b\u200b').replaceAll('http', 'http\u200b\u200b\u200b\u200b\u200b').replaceAll('\u001b[9', '\u001b[3');// .replace(/[\r\n]/gm, '\n') diff --git a/plugins/chat.js b/plugins/chat.js index f2c0220..815a8a2 100644 --- a/plugins/chat.js +++ b/plugins/chat.js @@ -18,7 +18,12 @@ function inject(bot) { bot.on('parsed_chat', (message, packet) => { try { const raw = message.toMotd().substring(0, 32767); - if (raw.match(/.* .*: .*/g)) { + if (raw.match(/.* .*:§r .*/g)) { + // if (packet.sender === '00000000-0000-0000-0000-000000000000') return; + const username = raw.replace(/.*?\[.*?\] /, '').replace(/:.*/g, '').replace(/§#....../gm, ''); + const message = raw.split(':§r ')[1]; + bot.emit('message', username, message, packet.sender); + } else if (raw.match(/.* .*: .*/g)) { // if (packet.sender === '00000000-0000-0000-0000-000000000000') return; const username = raw.replace(/.*?\[.*?\] /, '').replace(/:.*/g, '').replace(/§#....../gm, ''); const message = raw.split(': ')[1];