diff --git a/src/common/utils/EventTask.ts b/src/common/utils/EventTask.ts index cf497015..a513b958 100644 --- a/src/common/utils/EventTask.ts +++ b/src/common/utils/EventTask.ts @@ -150,7 +150,7 @@ export class NTEventWrapper { }); } async CallNormalEvent Promise, ListenerType extends (...args: any[]) => void> - (EventName = '', ListenerName = '', waitTimes = 1, timeout: number = 3000, checker: (...args: Parameters) => boolean, ...args: Parameters) { + (EventName = '', ListenerName = '', waitTimes = 1, timeout: number = 3000, checker: (...args: Parameters) => boolean, ...args: Parameters) { return new Promise<[EventRet: Awaited>, ...Parameters]>(async (resolve, reject) => { const id = randomUUID(); let complete = 0; diff --git a/src/core/src/apis/msg.ts b/src/core/src/apis/msg.ts index 847a9514..fbe1d799 100644 --- a/src/core/src/apis/msg.ts +++ b/src/core/src/apis/msg.ts @@ -1,9 +1,9 @@ -import { ChatType, ElementType, GetFileListParam, MessageElement, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; +import { GetFileListParam, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; import { friends, groups, selfInfo } from '@/core/data'; -import { log, logError, logWarn } from '@/common/utils/log'; +import { log, logWarn } from '@/common/utils/log'; import { sleep } from '@/common/utils/helper'; -import { napCatCore, NodeIKernelMsgService, NTQQUserApi } from '@/core'; -import { NodeIKernelMsgListener, onGroupFileInfoUpdateParamType } from '@/core/listeners'; +import { napCatCore, NTQQUserApi } from '@/core'; +import { onGroupFileInfoUpdateParamType } from '@/core/listeners'; import { GeneralCallResult } from '@/core/services/common'; import { MessageUnique } from '../../../common/utils/MessageUnique'; import { NTEventDispatch } from '@/common/utils/EventTask'; @@ -67,25 +67,6 @@ setTimeout(() => { // }, 25000) export class NTQQMsgApi { - // static async CheckSendMode() { - // try { - // NTQQMsgApi.sendMsgV2({ chatType: 1, peerUid: selfInfo.uid }, [SendMsgElementConstructor.text('消息队列模式测试')], true, 10000).then().catch(); - // MsgSendMode = 2; - // logNotice('[消息队列] 消息模式确认: MsgId异步队列'); - // return true; - // } catch (error) { - // logNotice('[消息队列] 消息模式失败: MsgId异步队列'); - // } - // try { - // NTQQMsgApi.sendMsgV1({ chatType: 1, peerUid: selfInfo.uid }, [SendMsgElementConstructor.text('消息队列模式测试')], true, 10000).then().catch(); - // MsgSendMode = 1; - // logNotice('[消息队列] 消息模式确认: MsgSeq异步队列'); - // return true; - // } catch (error) { - // logNotice('[消息队列] 消息模式失败: MsgSeq异步队列'); - // } - // return false; - // } // static napCatCore: NapCatCore | null = null; // enum BaseEmojiType { // NORMAL_EMOJI, diff --git a/src/onebot11/action/file/GetFile.ts b/src/onebot11/action/file/GetFile.ts index 1c9363ad..85672682 100644 --- a/src/onebot11/action/file/GetFile.ts +++ b/src/onebot11/action/file/GetFile.ts @@ -50,17 +50,17 @@ export class GetFileBase extends BaseAction { try { UuidData = UUIDConverter.decode(payload.file); if (UuidData) { - let peerUin = UuidData.high; - let msgId = UuidData.low; - let isGroup = await getGroup(peerUin); + const peerUin = UuidData.high; + const msgId = UuidData.low; + const isGroup = await getGroup(peerUin); let peer: Peer | undefined; //识别Peer if (isGroup) { peer = { chatType: ChatType.group, peerUid: peerUin }; } - let PeerUid = await NTQQUserApi.getUidByUin(peerUin); + const PeerUid = await NTQQUserApi.getUidByUin(peerUin); if (PeerUid) { - let isBuddy = await NTQQFriendApi.isBuddy(PeerUid); + const isBuddy = await NTQQFriendApi.isBuddy(PeerUid); if (isBuddy) { peer = { chatType: ChatType.friend, peerUid: PeerUid }; } else { @@ -70,18 +70,18 @@ export class GetFileBase extends BaseAction { if (!peer) { throw new Error('chattype not support'); } - let msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]); + const msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]); if (msgList.msgList.length == 0) { throw new Error('msg not found'); } - let msg = msgList.msgList[0]; - let findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT); + const msg = msgList.msgList[0]; + const findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT); if (!findEle) { throw new Error('element not found'); } - let downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', ''); - let fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0'; - let fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || ''; + const downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', ''); + const fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0'; + const fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || ''; const res: GetFileResponse = { file: downloadPath, url: downloadPath, diff --git a/src/onebot11/action/msg/GetMsg.ts b/src/onebot11/action/msg/GetMsg.ts index e320af19..29edde9e 100644 --- a/src/onebot11/action/msg/GetMsg.ts +++ b/src/onebot11/action/msg/GetMsg.ts @@ -36,7 +36,7 @@ class GetMsg extends BaseAction { const msg = await NTQQMsgApi.getMsgsByMsgId( peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()]); - let retMsg = await OB11Constructor.message(msg.msgList[0]); + const retMsg = await OB11Constructor.message(msg.msgList[0]); try { retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!; retMsg.message_seq = retMsg.message_id; diff --git a/src/onebot11/action/msg/SendMsg/create-send-elements.ts b/src/onebot11/action/msg/SendMsg/create-send-elements.ts index d1b3038e..6bb22514 100644 --- a/src/onebot11/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot11/action/msg/SendMsg/create-send-elements.ts @@ -27,7 +27,7 @@ async function handleOb11FileLikeMessage( { deleteAfterSentFiles }: MessageContext ) { //有的奇怪的框架将url作为参数 而不是file 此时优先url - let { path, isLocal, fileName, errMsg } = (await uri2local(inputdata?.url || inputdata.file)); + const { path, isLocal, fileName, errMsg } = (await uri2local(inputdata?.url || inputdata.file)); if (errMsg) { logError('文件下载失败', errMsg); diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index a520d252..d7ba6934 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -102,5 +102,5 @@ export enum ActionName { SetGroupHeader = 'set_group_head', FetchCustomFace = 'fetch_custom_face', GOCQHTTP_UploadPrivateFile = 'upload_private_file', - TestApi01 = "test_api_01" + TestApi01 = 'test_api_01' }