From f368f4f040581f472c2d717cd43cd324ceebc5e2 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Thu, 30 Mar 2023 12:12:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96qq=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/face.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/face.js b/utils/face.js index d2ad570..607d48e 100644 --- a/utils/face.js +++ b/utils/face.js @@ -1,4 +1,5 @@ -// import { segment } from 'oicq' +import _ from 'lodash' +import {segment} from "oicq"; export const faceMap = { 0: '惊讶', 1: '撇嘴', @@ -506,11 +507,11 @@ export async function convertFaces (msg, handleAt = false, e) { tmpFace += msg[i] } else { foundFace = false - if (faceMapReverse[tmpFace]) { + if (faceMapReverse[tmpFace] || faceMapReverse['/' + tmpFace] || faceMapReverse[_.trimStart(tmpFace, '/')]) { if (tmpMsg) { msgs.push(tmpMsg) } - msgs.push(segment.face(parseInt(faceMapReverse[tmpFace]))) + msgs.push(segment.face(parseInt(faceMapReverse[tmpFace] || faceMapReverse['/' + tmpFace] || faceMapReverse[_.trimStart(tmpFace, '/')]))) tmpMsg = '' } else { tmpMsg += `[${tmpFace}]` @@ -533,11 +534,11 @@ export async function convertFaces (msg, handleAt = false, e) { export function testConvertFaces () { const toTest = [ - '你好啊[微笑][惊讶]' + '你好啊[/微笑][惊讶]哈哈[/拜谢]' ] toTest.forEach(t => { console.log(convertFaces(t)) }) } -// testConvertFaces() +testConvertFaces()