support [a] b > message and fix other chat stuff

This commit is contained in:
ChomeNS 2022-11-28 17:25:54 +07:00
parent 58d5b078d8
commit e9134745aa

View file

@ -48,19 +48,23 @@ function parsePlayerMessages (message, packet, bot) {
const raw = message.toMotd().substring(0, 32767)
if (raw.match(/.* .*: .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '')
const message = raw.split(': ')[1]
const message = raw.split(': ').slice(1).join(' ').replace(/§#....../gm, '')
bot.emit('message', username, message, packet.sender)
} else if (raw.match(/.* .*\u203a .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('\u203a ')[1].substring(2)
const message = raw.split('\u203a ').slice(1).join(' ').substring(2)
bot.emit('message', username, message, packet.sender)
} else if (raw.match(/.* .*\u00BB .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('\u00BB ')[1].substring(2)
const message = raw.split('\u00BB ').slice(1).join(' ').substring(2)
bot.emit('message', username, message, packet.sender)
} else if (raw.match(/.* .*> .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/>.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('> ').slice(1).join(' ').substring(2)
bot.emit('message', username, message, packet.sender)
} else if (raw.match(/<.*> .*/g)) {
const username = raw.substring(1).split('>')[0]
const message = raw.split('> ')[1]
const message = raw.split('> ').slice(1).join(' ')
bot.emit('message', username, message, packet.sender)
} else if (raw.match(/§.*§b: §b\/.*/g)) {