style: 代码质量提高

This commit is contained in:
手瓜一十雪 2024-08-26 00:05:33 +08:00
parent c64367335c
commit ab955e41fb
2 changed files with 31 additions and 33 deletions
src
core/apis
onebot/action/msg

@ -271,7 +271,7 @@ export class NTQQFileApi {
md5HexStr: md5, md5HexStr: md5,
fileSize: fileSize, fileSize: fileSize,
// duration: Math.max(1, Math.round(fileSize / 1024 / 3)), // 一秒钟大概是3kb大小, 小于1秒的按1秒算 // duration: Math.max(1, Math.round(fileSize / 1024 / 3)), // 一秒钟大概是3kb大小, 小于1秒的按1秒算
duration: duration || 1, duration: duration ?? 1,
formatType: 1, formatType: 1,
voiceType: 1, voiceType: 1,
voiceChangeType: 0, voiceChangeType: 0,
@ -319,30 +319,30 @@ export class NTQQFileApi {
filePath: string filePath: string
}) => Promise<unknown>, }) => Promise<unknown>,
(fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void (fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void
>( >(
'NodeIKernelMsgService/downloadRichMedia', 'NodeIKernelMsgService/downloadRichMedia',
'NodeIKernelMsgListener/onRichMediaDownloadComplete', 'NodeIKernelMsgListener/onRichMediaDownloadComplete',
1, 1,
timeout, timeout,
(arg: OnRichMediaDownloadCompleteParams) => { (arg: OnRichMediaDownloadCompleteParams) => {
if (arg.msgId === msgId) { if (arg.msgId === msgId) {
return true; return true;
} }
return false; return false;
}, },
{ {
fileModelId: '0', fileModelId: '0',
downloadSourceType: 0, downloadSourceType: 0,
triggerType: 1, triggerType: 1,
msgId: msgId, msgId: msgId,
chatType: chatType, chatType: chatType,
peerUid: peerUid, peerUid: peerUid,
elementId: elementId, elementId: elementId,
thumbSize: 0, thumbSize: 0,
downloadType: 1, downloadType: 1,
filePath: thumbPath, filePath: thumbPath,
}, },
); );
const msg = await this.core.apis.MsgApi.getMsgsByMsgId({ const msg = await this.core.apis.MsgApi.getMsgsByMsgId({
guildId: '', guildId: '',
chatType: chatType, chatType: chatType,
@ -482,10 +482,10 @@ export class NTQQFileApi {
let id = ''; let id = '';
const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void> const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void>
( (
'NodeIKernelSearchListener/onSearchFileKeywordsResult', 'NodeIKernelSearchListener/onSearchFileKeywordsResult',
1, 1,
20000, 20000,
(params) => id !== '' && params.searchId == id, (params) => id !== '' && params.searchId == id,
); );
id = await Event!(keys, 12); id = await Event!(keys, 12);
const [ret] = (await Listener); const [ret] = (await Listener);

@ -238,9 +238,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
const AllElement: SendMessageElement[][] = [MixElement, ...SingleElement].filter(e => e !== undefined && e.length !== 0); const AllElement: SendMessageElement[][] = [MixElement, ...SingleElement].filter(e => e !== undefined && e.length !== 0);
const MsgNodeList: Promise<RawMessage | undefined>[] = []; const MsgNodeList: Promise<RawMessage | undefined>[] = [];
for (const sendElementsSplitElement of AllElement) { for (const sendElementsSplitElement of AllElement) {
MsgNodeList.push(sendMsg(this.CoreContext, selfPeer, sendElementsSplitElement, [], true).catch(_ => new Promise((resolve) => { MsgNodeList.push(sendMsg(this.CoreContext, selfPeer, sendElementsSplitElement, [], true).catch(_ => undefined));
resolve(undefined);
})));
} }
(await Promise.allSettled(MsgNodeList)).map((result) => { (await Promise.allSettled(MsgNodeList)).map((result) => {
if (result.status === 'fulfilled' && result.value) { if (result.status === 'fulfilled' && result.value) {
@ -301,7 +299,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
}; };
const logger = this.CoreContext.context.logger; const logger = this.CoreContext.context.logger;
const NTQQMsgApi = this.CoreContext.apis.MsgApi; const NTQQMsgApi = this.CoreContext.apis.MsgApi;
//logDebug('克隆的目标消息', msg); //msg 为待克隆消息
const sendElements: SendMessageElement[] = []; const sendElements: SendMessageElement[] = [];