fix: 优化qq表情适配

This commit is contained in:
ikechan8370 2023-03-30 12:12:28 +08:00
parent bae27b7362
commit f368f4f040

View file

@ -1,4 +1,5 @@
// import { segment } from 'oicq' import _ from 'lodash'
import {segment} from "oicq";
export const faceMap = { export const faceMap = {
0: '惊讶', 0: '惊讶',
1: '撇嘴', 1: '撇嘴',
@ -506,11 +507,11 @@ export async function convertFaces (msg, handleAt = false, e) {
tmpFace += msg[i] tmpFace += msg[i]
} else { } else {
foundFace = false foundFace = false
if (faceMapReverse[tmpFace]) { if (faceMapReverse[tmpFace] || faceMapReverse['/' + tmpFace] || faceMapReverse[_.trimStart(tmpFace, '/')]) {
if (tmpMsg) { if (tmpMsg) {
msgs.push(tmpMsg) msgs.push(tmpMsg)
} }
msgs.push(segment.face(parseInt(faceMapReverse[tmpFace]))) msgs.push(segment.face(parseInt(faceMapReverse[tmpFace] || faceMapReverse['/' + tmpFace] || faceMapReverse[_.trimStart(tmpFace, '/')])))
tmpMsg = '' tmpMsg = ''
} else { } else {
tmpMsg += `[${tmpFace}]` tmpMsg += `[${tmpFace}]`
@ -533,11 +534,11 @@ export async function convertFaces (msg, handleAt = false, e) {
export function testConvertFaces () { export function testConvertFaces () {
const toTest = [ const toTest = [
'你好啊[微笑][惊讶]' '你好啊[/微笑][惊讶]哈哈[/拜谢]'
] ]
toTest.forEach(t => { toTest.forEach(t => {
console.log(convertFaces(t)) console.log(convertFaces(t))
}) })
} }
// testConvertFaces() testConvertFaces()