botv12/chatParsers/chat_system.js

41 lines
1,002 B
JavaScript
Raw Normal View History

2024-11-19 20:10:10 -05:00
import parsePlain from '../util/chatparse_plain.js'
2024-10-22 23:11:33 -04:00
const priority = 2
const parse = (data, b) => {
if (data.type === 'system' || data.type === 'legacy') {
let subtype = 'generic_system'
if (data.type === 'legacy' && data.uuid) subtype += '_withuuid'
const parsed = parsePlain(data.json)
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const chatNameSplit = chatName.split(' ')
let uuid
let username
let nickname
if (data.uuid) {
uuid = data.uuid
username = b.findRealNameFromUUID(uuid)
nickname = b.findDisplayName(uuid)
} else {
nickname = chatNameSplit[chatNameSplit.length - 1]
username = b.findRealName(chatName)
uuid = b.findUUID(username)
}
return {
parsed: true,
json: data.json,
type: data.type,
subtype,
uuid,
message: split.join(': '),
nickname,
username
}
}
return {
parsed: false
}
}
2024-11-19 20:05:19 -05:00
export { priority, parse }