fix chat on kitsune + filter braille

This commit is contained in:
ChomeNS 2022-10-25 12:23:05 +07:00
parent 876d28ed15
commit 99e28d5360
2 changed files with 8 additions and 1 deletions

View file

@ -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')

View file

@ -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];