mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: try 2 fix cannot parse msg err
This commit is contained in:
parent
1da086ce0a
commit
43e9b070a9
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@ package-lock.json
|
|||||||
dist/
|
dist/
|
||||||
out/
|
out/
|
||||||
.idea/
|
.idea/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 4,
|
"manifest_version": 4,
|
||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "LLOneBot v3.24.1",
|
"name": "LLOneBot v3.24.2",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
||||||
"version": "3.24.1",
|
"version": "3.24.2",
|
||||||
"icon": "./icon.jpg",
|
"icon": "./icon.jpg",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"deploy-mac": "cp -r dist/* ~/Library/Containers/com.tencent.qq/Data/LiteLoaderQQNT/plugins/LLOneBot/",
|
"deploy-mac": "cp -r dist/* ~/Library/Containers/com.tencent.qq/Data/LiteLoaderQQNT/plugins/LLOneBot/",
|
||||||
"build-win": "npm run build && npm run deploy-win",
|
"build-win": "npm run build && npm run deploy-win",
|
||||||
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %USERPROFILE%\\documents\\LiteLoaderQQNT\\plugins\\LLOneBot\\\"",
|
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %USERPROFILE%\\documents\\LiteLoaderQQNT\\plugins\\LLOneBot\\\"",
|
||||||
"format": "prettier -cw ."
|
"format": "prettier -cw .",
|
||||||
|
"check": "tsc"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -74,7 +74,11 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
static async getGroupIgnoreNotifies() {
|
static async getGroupIgnoreNotifies() {
|
||||||
await NTQQGroupApi.getGroupNotifies()
|
await NTQQGroupApi.getGroupNotifies()
|
||||||
return await NTQQWindowApi.openWindow(NTQQWindows.GroupNotifyFilterWindow, [], ReceiveCmdS.GROUP_NOTIFY)
|
return await NTQQWindowApi.openWindow<GeneralCallResult & GroupNotifies>(
|
||||||
|
NTQQWindows.GroupNotifyFilterWindow,
|
||||||
|
[],
|
||||||
|
ReceiveCmdS.GROUP_NOTIFY,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
static async handleGroupRequest(seq: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
static async handleGroupRequest(seq: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
||||||
const notify: GroupNotify = await dbUtil.getGroupNotify(seq)
|
const notify: GroupNotify = await dbUtil.getGroupNotify(seq)
|
||||||
|
@ -14,11 +14,13 @@ import { friends, getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } f
|
|||||||
import {
|
import {
|
||||||
OB11MessageCustomMusic,
|
OB11MessageCustomMusic,
|
||||||
OB11MessageData,
|
OB11MessageData,
|
||||||
OB11MessageDataType, OB11MessageFile,
|
OB11MessageDataType,
|
||||||
|
OB11MessageFile,
|
||||||
OB11MessageJson,
|
OB11MessageJson,
|
||||||
OB11MessageMixType,
|
OB11MessageMixType,
|
||||||
OB11MessageMusic,
|
OB11MessageMusic,
|
||||||
OB11MessageNode, OB11MessageVideo,
|
OB11MessageNode,
|
||||||
|
OB11MessageVideo,
|
||||||
OB11PostSendMsg,
|
OB11PostSendMsg,
|
||||||
} from '../../types'
|
} from '../../types'
|
||||||
import { NTQQMsgApi, Peer } from '../../../ntqqapi/api/msg'
|
import { NTQQMsgApi, Peer } from '../../../ntqqapi/api/msg'
|
||||||
@ -177,11 +179,18 @@ export async function createSendElements(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case OB11MessageDataType.mface: {
|
case OB11MessageDataType.mface:
|
||||||
sendElements.push(
|
{
|
||||||
SendMsgElementConstructor.mface(sendMsg.data.emoji_package_id, sendMsg.data.emoji_id, sendMsg.data.key, sendMsg.data.summary),
|
sendElements.push(
|
||||||
)
|
SendMsgElementConstructor.mface(
|
||||||
}break;
|
sendMsg.data.emoji_package_id,
|
||||||
|
sendMsg.data.emoji_id,
|
||||||
|
sendMsg.data.key,
|
||||||
|
sendMsg.data.summary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
break
|
||||||
case OB11MessageDataType.image:
|
case OB11MessageDataType.image:
|
||||||
case OB11MessageDataType.file:
|
case OB11MessageDataType.file:
|
||||||
case OB11MessageDataType.video:
|
case OB11MessageDataType.video:
|
||||||
@ -303,14 +312,14 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
|
|
||||||
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
const messages = convertMessage2List(payload.message)
|
const messages = convertMessage2List(payload.message)
|
||||||
const fmNum = this.getSpecialMsgNum(payload, OB11MessageDataType.node)
|
const fmNum = this.getSpecialMsgNum(messages, OB11MessageDataType.node)
|
||||||
if (fmNum && fmNum != messages.length) {
|
if (fmNum && fmNum != messages.length) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const musicNum = this.getSpecialMsgNum(payload, OB11MessageDataType.music)
|
const musicNum = this.getSpecialMsgNum(messages, OB11MessageDataType.music)
|
||||||
if (musicNum && messages.length > 1) {
|
if (musicNum && messages.length > 1) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
@ -382,14 +391,14 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
payload.message,
|
payload.message,
|
||||||
payload.auto_escape === true || payload.auto_escape === 'true',
|
payload.auto_escape === true || payload.auto_escape === 'true',
|
||||||
)
|
)
|
||||||
if (this.getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
if (this.getSpecialMsgNum(messages, OB11MessageDataType.node)) {
|
||||||
try {
|
try {
|
||||||
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group)
|
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group)
|
||||||
return { message_id: returnMsg.msgShortId }
|
return { message_id: returnMsg.msgShortId }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw '发送转发消息失败 ' + e.toString()
|
throw '发送转发消息失败 ' + e.toString()
|
||||||
}
|
}
|
||||||
} else if (this.getSpecialMsgNum(payload, OB11MessageDataType.music)) {
|
} else if (this.getSpecialMsgNum(messages, OB11MessageDataType.music)) {
|
||||||
const music = messages[0] as OB11MessageMusic
|
const music = messages[0] as OB11MessageMusic
|
||||||
if (music) {
|
if (music) {
|
||||||
const { musicSignUrl } = getConfigUtil().getConfig()
|
const { musicSignUrl } = getConfigUtil().getConfig()
|
||||||
@ -402,24 +411,23 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
const postData: MusicSignPostData = { ...music.data }
|
const postData: MusicSignPostData = { ...music.data }
|
||||||
if (type === 'custom' && music.data.content) {
|
if (type === 'custom' && music.data.content) {
|
||||||
|
|
||||||
;(postData as CustomMusicSignPostData).singer = music.data.content
|
;(postData as CustomMusicSignPostData).singer = music.data.content
|
||||||
delete (postData as OB11MessageCustomMusic['data']).content
|
delete (postData as OB11MessageCustomMusic['data']).content
|
||||||
}
|
}
|
||||||
if (type === 'custom'){
|
if (type === 'custom') {
|
||||||
const customMusicData = music.data as CustomMusicSignPostData
|
const customMusicData = music.data as CustomMusicSignPostData
|
||||||
if (!customMusicData.url){
|
if (!customMusicData.url) {
|
||||||
throw ('自定义音卡缺少参数url');
|
throw '自定义音卡缺少参数url'
|
||||||
}
|
}
|
||||||
if (!customMusicData.audio){
|
if (!customMusicData.audio) {
|
||||||
throw('自定义音卡缺少参数audio');
|
throw '自定义音卡缺少参数audio'
|
||||||
}
|
}
|
||||||
if (!customMusicData.title){
|
if (!customMusicData.title) {
|
||||||
throw('自定义音卡缺少参数title');
|
throw '自定义音卡缺少参数title'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === 'qq' || type === '163') {
|
if (type === 'qq' || type === '163') {
|
||||||
const idMusicData = music.data as IdMusicSignPostData;
|
const idMusicData = music.data as IdMusicSignPostData
|
||||||
if (!idMusicData.id) {
|
if (!idMusicData.id) {
|
||||||
throw '音乐卡片缺少id参数'
|
throw '音乐卡片缺少id参数'
|
||||||
}
|
}
|
||||||
@ -448,9 +456,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
return { message_id: returnMsg.msgShortId }
|
return { message_id: returnMsg.msgShortId }
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSpecialMsgNum(payload: OB11PostSendMsg, msgType: OB11MessageDataType): number {
|
private getSpecialMsgNum(message: OB11MessageData[], msgType: OB11MessageDataType): number {
|
||||||
if (Array.isArray(payload.message)) {
|
if (Array.isArray(message)) {
|
||||||
return payload.message.filter((msg) => msg.type == msgType).length
|
return message.filter((msg) => msg.type == msgType).length
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
// "sourceMap": true
|
// "sourceMap": true,
|
||||||
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["src/*", "src/**/*", "scripts/*"],
|
"include": ["src/*", "src/**/*", "scripts/*"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user