botv12/chatParsers/chat_cmm.js

47 lines
No EOL
1.3 KiB
JavaScript
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { parse2 as parsePlain } from '../util/chatparse_plain.js'
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
}
}
export { priority, parse }