Skip to content

Commit

Permalink
[nl]紧急修正:消息发送转换异常
Browse files Browse the repository at this point in the history
💩 屎,去掉了写死再配置文件里的消息类型少改了个地方
💚 [build-electron]
  • Loading branch information
Stapxs committed Jul 15, 2024
1 parent eff6664 commit ce6e656
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stapxs-qq-lite",
"version": "2.7.15",
"version": "2.7.16",
"private": false,
"author": "Stapx Steve [林槐]",
"description": "一个兼容 OneBot 的非官方网页版 QQ 客户端,使用 Vue 重制的全新版本。",
Expand Down
2 changes: 1 addition & 1 deletion src/function/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function updateGTKColor(value: boolean) {

function setMsgType(value: any) {
if(value) {
runtimeData.tags.msgType = value
runtimeData.tags.msgType = Number(value)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/function/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export function parseMsg(msg: string, cache: MsgItemElem[], img: string[]) {
}
// 处理消息
let back = undefined
if (runtimeData.tags.msgType === BotMsgType.Array) {
if (runtimeData.tags.msgType == BotMsgType.Array) {
back = parseMsgToJSON(msg, cache)
} else if (runtimeData.tags.msgType === BotMsgType.CQCode) {
} else if (runtimeData.tags.msgType == BotMsgType.CQCode) {
back = parseMsgToCQ(msg, cache)
}
return back
Expand Down
58 changes: 27 additions & 31 deletions src/function/utils/msgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,38 +347,34 @@ export function sendMsgRaw(id: string, type: string, msg: string | { type: strin
runtimeData.messageList = runtimeData.messageList.concat([showMsg])
}
// 检查消息体是否需要处理
const messageType = runtimeData.jsonMap.message_list.type.split('|')[0]
switch (messageType) {
case 'json_with_data': {
const map = runtimeData.jsonMap.message_list.type.split('|')[1]
const path = jp.parse(map)
const keys = [] as string[]
path.forEach((item) => {
if (item.expression.value != '*' && item.expression.value != '$') {
keys.push(item.expression.value)
}
})
if(msg && typeof msg != 'string') {
const newMsg = [] as any
msg.forEach((item) => {
const result = {} as any
keys.reduce((acc, key, index) => {
if (index === keys.length - 1) {
acc[key] = item
} else {
acc[key] = {}
}
return acc[key]
}, result)
const newResult = {} as {[key: string]: any}
newResult.type = item.type
newResult.data = item
delete newResult.data.type
newMsg.push(newResult)
})
msg = newMsg
if (runtimeData.tags.msgType == BotMsgType.Array) {
const map = runtimeData.jsonMap.message_list.type
const path = jp.parse(map)
const keys = [] as string[]
path.forEach((item) => {
if (item.expression.value != '*' && item.expression.value != '$') {
keys.push(item.expression.value)
}
break
})
if (msg && typeof msg != 'string') {
const newMsg = [] as any
msg.forEach((item) => {
const result = {} as any
keys.reduce((acc, key, index) => {
if (index === keys.length - 1) {
acc[key] = item
} else {
acc[key] = {}
}
return acc[key]
}, result)
const newResult = {} as { [key: string]: any }
newResult.type = item.type
newResult.data = item
delete newResult.data.type
newMsg.push(newResult)
})
msg = newMsg
}
}
if (msg !== undefined && msg.length > 0) {
Expand Down

0 comments on commit ce6e656

Please sign in to comment.