botv12/chatParsers/chat_cmm.js

48 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2024-11-19 20:05:19 -05:00
import parsePlain from '../util/chatparse_plain.js'
2024-10-22 23:11:33 -04:00
const priority = 0
const parse = (data, b) => {
if (data.type === 'system' || data.type === 'legacy') {
if (data.json.translate === '%s %s %s' || data.json.translate === '[%s] %s %s') {
let subtype = 'chipmunkmod_'
if (data.json.translate === '%s %s %s') {
subtype += 'name3'
} else if (data.json.translate === '[%s] %s %s') {
subtype += 'chomens'
}
if (data.json.with && data.json.with[1] && data.json.with[2]) {
const username = parsePlain(data.json.with[1])
const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid)
const message = parsePlain(data.json.with[2])
return {
parsed: true,
json: data.json,
type: data.type,
subtype,
uuid,
message,
nickname,
username
}
} else {
subtype += '_invalid'
return {
parsed: true,
json: data.json,
type: data.type,
subtype,
uuid: '00000000-0000-0000-0000-000000000000',
message: '',
nickname: '',
username: ''
}
}
}
}
return {
parsed: false
}
}
2024-11-19 20:05:19 -05:00
export { priority, parse }