From b50556802c63126565e32ff32955bd8e0f3a73e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 9 Aug 2024 18:28:05 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20action=E5=9F=BA=E6=9C=AC=E5=B0=B1?= =?UTF-8?q?=E7=BB=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts | 4 ++-- src/onebot/action/go-cqhttp/UploadGroupFile.ts | 2 +- src/onebot/action/go-cqhttp/UploadPrivareFile.ts | 2 +- src/onebot/action/group/SetGroupAdmin.ts | 5 ++++- src/onebot/action/msg/GetMsg.ts | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts index b899cb2b..e694c046 100644 --- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts @@ -48,12 +48,12 @@ export default class GetFriendMsgHistory extends BaseAction { if (!startMsgId) throw `消息${payload.message_seq}不存在`; msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList; } - if(isReverseOrder) msgList.reverse(); + if (isReverseOrder) msgList.reverse(); await Promise.all(msgList.map(async msg => { msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId); })); //转换消息 - const ob11MsgList = await Promise.all(msgList.map(msg => OB11Constructor.message(msg))); + const ob11MsgList = await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, "array"))); return { 'messages': ob11MsgList }; } } diff --git a/src/onebot/action/go-cqhttp/UploadGroupFile.ts b/src/onebot/action/go-cqhttp/UploadGroupFile.ts index be1eb2e9..1632c888 100644 --- a/src/onebot/action/go-cqhttp/UploadGroupFile.ts +++ b/src/onebot/action/go-cqhttp/UploadGroupFile.ts @@ -33,7 +33,7 @@ export default class GoCQHTTPUploadGroupFile extends BaseAction { throw new Error(downloadResult.errMsg); } const sendFileEle: SendFileElement = await SendMsgElementConstructor.file(this.CoreContext, downloadResult.path, payload.name, payload.folder_id); - await sendMsg({ chatType: ChatType.group, peerUid: payload.group_id.toString() }, [sendFileEle], [], true); + await sendMsg(this.CoreContext, { chatType: ChatType.group, peerUid: payload.group_id.toString() }, [sendFileEle], [], true); return null; } } diff --git a/src/onebot/action/go-cqhttp/UploadPrivareFile.ts b/src/onebot/action/go-cqhttp/UploadPrivareFile.ts index 2a88e033..8f0f5c0e 100644 --- a/src/onebot/action/go-cqhttp/UploadPrivareFile.ts +++ b/src/onebot/action/go-cqhttp/UploadPrivareFile.ts @@ -45,7 +45,7 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction throw new Error(downloadResult.errMsg); } const sendFileEle: SendFileElement = await SendMsgElementConstructor.file(this.CoreContext, downloadResult.path, payload.name); - await sendMsg(peer, [sendFileEle], [], true); + await sendMsg(this.CoreContext, peer, [sendFileEle], [], true); return null; } } diff --git a/src/onebot/action/group/SetGroupAdmin.ts b/src/onebot/action/group/SetGroupAdmin.ts index b187b306..4f9feb27 100644 --- a/src/onebot/action/group/SetGroupAdmin.ts +++ b/src/onebot/action/group/SetGroupAdmin.ts @@ -21,7 +21,10 @@ export default class SetGroupAdmin extends BaseAction { PayloadSchema = SchemaData; protected async _handle(payload: Payload): Promise { const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi; - await NTQQGroupApi.setMemberRole(payload.group_id.toString(), member.uid, enable ? GroupMemberRole.admin : GroupMemberRole.normal); + const NTQQUserApi = this.CoreContext.getApiContext().UserApi; + let uid = await NTQQUserApi.getUidByUin(payload.user_id.toString()) + if(!uid) throw new Error('get Uid Error') + await NTQQGroupApi.setMemberRole(payload.group_id.toString(), uid, payload.enable ? GroupMemberRole.admin : GroupMemberRole.normal); return null; } } diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts index 62a80bdb..4f84d8ae 100644 --- a/src/onebot/action/msg/GetMsg.ts +++ b/src/onebot/action/msg/GetMsg.ts @@ -36,7 +36,7 @@ class GetMsg extends BaseAction { const msg = await NTQQMsgApi.getMsgsByMsgId( peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()]); - const retMsg = await OB11Constructor.message(msg.msgList[0]); + const retMsg = await OB11Constructor.message(this.CoreContext, msg.msgList[0], "array"); try { retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!; retMsg.message_seq = retMsg.message_id;