From 9da714bf156cc8e6ec7cea9c349f8477c10526af 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: Mon, 26 Aug 2024 00:17:42 +0800 Subject: [PATCH] style: fix --- src/core/apis/file.ts | 56 +++++++++---------- src/onebot/action/extends/FetchCustomFace.ts | 2 +- src/onebot/action/extends/FetchEmojiLike.ts | 2 +- .../action/extends/GetCollectionList.ts | 2 +- .../action/go-cqhttp/GetFriendMsgHistory.ts | 4 +- .../action/go-cqhttp/GetGroupMsgHistory.ts | 4 +- .../action/go-cqhttp/SendGroupNotice.ts | 2 - src/onebot/action/user/GetRecentContact.ts | 2 +- src/onebot/api/msg.ts | 9 ++- 9 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 5982d6dc..0d32ad39 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -319,30 +319,30 @@ export class NTQQFileApi { filePath: string }) => Promise, (fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void - >( - 'NodeIKernelMsgService/downloadRichMedia', - 'NodeIKernelMsgListener/onRichMediaDownloadComplete', - 1, - timeout, - (arg: OnRichMediaDownloadCompleteParams) => { - if (arg.msgId === msgId) { - return true; - } - return false; - }, - { - fileModelId: '0', - downloadSourceType: 0, - triggerType: 1, - msgId: msgId, - chatType: chatType, - peerUid: peerUid, - elementId: elementId, - thumbSize: 0, - downloadType: 1, - filePath: thumbPath, - }, - ); + >( + 'NodeIKernelMsgService/downloadRichMedia', + 'NodeIKernelMsgListener/onRichMediaDownloadComplete', + 1, + timeout, + (arg: OnRichMediaDownloadCompleteParams) => { + if (arg.msgId === msgId) { + return true; + } + return false; + }, + { + fileModelId: '0', + downloadSourceType: 0, + triggerType: 1, + msgId: msgId, + chatType: chatType, + peerUid: peerUid, + elementId: elementId, + thumbSize: 0, + downloadType: 1, + filePath: thumbPath, + }, + ); const msg = await this.core.apis.MsgApi.getMsgsByMsgId({ guildId: '', chatType: chatType, @@ -482,10 +482,10 @@ export class NTQQFileApi { let id = ''; const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void> ( - 'NodeIKernelSearchListener/onSearchFileKeywordsResult', - 1, - 20000, - (params) => id !== '' && params.searchId == id, + 'NodeIKernelSearchListener/onSearchFileKeywordsResult', + 1, + 20000, + (params) => id !== '' && params.searchId == id, ); id = await Event!(keys, 12); const [ret] = (await Listener); diff --git a/src/onebot/action/extends/FetchCustomFace.ts b/src/onebot/action/extends/FetchCustomFace.ts index 14bdf610..d9ed5fef 100644 --- a/src/onebot/action/extends/FetchCustomFace.ts +++ b/src/onebot/action/extends/FetchCustomFace.ts @@ -17,7 +17,7 @@ export class FetchCustomFace extends BaseAction { async _handle(payload: Payload) { //48 可能正好是QQ需要的一个页面的数量 Tagged Mlikiowa - const ret = await this.CoreContext.apis.MsgApi.fetchFavEmojiList(parseInt((payload.count || '0').toString()) || 48); + const ret = await this.CoreContext.apis.MsgApi.fetchFavEmojiList(+(payload.count ?? 48)); return ret.emojiInfoList.map(e => e.url); } } diff --git a/src/onebot/action/extends/FetchEmojiLike.ts b/src/onebot/action/extends/FetchEmojiLike.ts index 2d9a9ce6..af89b111 100644 --- a/src/onebot/action/extends/FetchEmojiLike.ts +++ b/src/onebot/action/extends/FetchEmojiLike.ts @@ -27,6 +27,6 @@ export class FetchEmojiLike extends BaseAction { const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); if (!msgIdPeer) throw new Error('消息不存在'); const msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0]; - return await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, parseInt((payload.count || '0').toString()) || 20); + return await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, +(payload.count ?? 20)); } } diff --git a/src/onebot/action/extends/GetCollectionList.ts b/src/onebot/action/extends/GetCollectionList.ts index ebc82e2b..c7d3e1b6 100644 --- a/src/onebot/action/extends/GetCollectionList.ts +++ b/src/onebot/action/extends/GetCollectionList.ts @@ -18,6 +18,6 @@ export class GetCollectionList extends BaseAction { PayloadSchema = SchemaData; async _handle(payload: Payload) { const NTQQCollectionApi = this.CoreContext.apis.CollectionApi; - return await NTQQCollectionApi.getAllCollection(parseInt(payload.category.toString()), parseInt(payload.count.toString())); + return await NTQQCollectionApi.getAllCollection(parseInt(payload.category.toString()), +(payload.count ?? 1)); } } diff --git a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts index 9b436a1f..7be0bb10 100644 --- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts @@ -14,7 +14,7 @@ const SchemaData = { properties: { user_id: { type: ['number', 'string'] }, message_seq: { type: 'number' }, - count: { type: 'number' }, + count: { type: ['number', 'string'] }, reverseOrder: { type: 'boolean' }, }, required: ['user_id'], @@ -32,7 +32,7 @@ export default class GetFriendMsgHistory extends BaseAction { const NTQQFriendApi = this.CoreContext.apis.FriendApi; //处理参数 const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString()); - const MsgCount = payload.count || 20; + const MsgCount = +(payload.count ?? 20); const isReverseOrder = payload.reverseOrder || true; if (!uid) throw `记录${payload.user_id}不存在`; const friend = await NTQQFriendApi.isBuddy(uid); diff --git a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts index 43d413f0..fd83bb5e 100644 --- a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts @@ -14,7 +14,7 @@ const SchemaData = { properties: { group_id: { type: ['number', 'string'] }, message_seq: { type: 'number' }, - count: { type: 'number' }, + count: { type: ['number', 'string'] }, reverseOrder: { type: 'boolean' }, }, required: ['group_id'], @@ -30,7 +30,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction { if (PublishGroupBulletinResult.result != 0) { throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`; } - // 下面实现扬了 - //await WebApi.setGroupNotice(payload.group_id, payload.content) ; return null; } } diff --git a/src/onebot/action/user/GetRecentContact.ts b/src/onebot/action/user/GetRecentContact.ts index dc243983..c46cf50e 100644 --- a/src/onebot/action/user/GetRecentContact.ts +++ b/src/onebot/action/user/GetRecentContact.ts @@ -18,7 +18,7 @@ export default class GetRecentContact extends BaseAction { async _handle(payload: Payload) { const NTQQUserApi = this.CoreContext.apis.UserApi; const NTQQMsgApi = this.CoreContext.apis.MsgApi; - const ret = await NTQQUserApi.getRecentContactListSnapShot(parseInt((payload.count || 10).toString())); + const ret = await NTQQUserApi.getRecentContactListSnapShot(+(payload.count || 10)); return await Promise.all(ret.info.changedList.map(async (t) => { const FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]); if (FastMsg.msgList.length > 0) { diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index 102956a8..14b7f2a8 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -21,8 +21,7 @@ import { OB11MessageData, OB11MessageDataType, OB11MessageFileBase, - OB11MessageForward, - OB11MessageReply, + OB11MessageForward } from '@/onebot'; import { OB11Constructor } from '../helper'; import { EventType } from '@/onebot/event/OB11BaseEvent'; @@ -447,8 +446,8 @@ export class OneBotMsgApi { replyElement: { replayMsgSeq: replyMsg.msgSeq, // raw.msgSeq replayMsgId: replyMsg.msgId, // raw.msgId - senderUin: replyMsg.senderUin!, - senderUinStr: replyMsg.senderUin!, + senderUin: replyMsg.senderUin, + senderUinStr: replyMsg.senderUin, }, } : undefined; @@ -793,6 +792,6 @@ export class OneBotMsgApi { deleteAfterSentFiles.push(path); } - return { path, fileName: inputdata.name || fileName }; + return { path, fileName: inputdata.name ?? fileName }; } }