diff --git a/src/onebot/action/msg/SendMsg.ts b/src/onebot/action/msg/SendMsg.ts index dacc8350..a7ae999e 100644 --- a/src/onebot/action/msg/SendMsg.ts +++ b/src/onebot/action/msg/SendMsg.ts @@ -194,7 +194,7 @@ export class SendMsg extends BaseAction { logger.logDebug(`handleForwardedNodesPacket[SendRaw] 开始转换 ${stringifyWithBigInt(packetMsgElements)}`); const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgWithSendMsgToPacketMsg(packetMsgElements); logger.logDebug(`handleForwardedNodesPacket[SendRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`); - packetMsg.push(transformedMsg!); + packetMsg.push(transformedMsg); } else if (node.data.id) { const id = node.data.id; const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(+id) || MessageUnique.getPeerByMsgId(id); @@ -207,7 +207,7 @@ export class SendMsg extends BaseAction { await this.core.apis.FileApi.downloadRawMsgMedia([msg]); const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgToPacketMsg(msg, msgPeer); logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`); - packetMsg.push(transformedMsg!); + packetMsg.push(transformedMsg); } else { logger.logDebug(`handleForwardedNodesPacket 跳过元素 ${stringifyWithBigInt(node)}`); } diff --git a/src/onebot/api/group.ts b/src/onebot/api/group.ts index ca5ed920..a22b42fc 100644 --- a/src/onebot/api/group.ts +++ b/src/onebot/api/group.ts @@ -171,7 +171,7 @@ export class OneBotGroupApi { let duration = parseInt(groupElement.shutUp!.duration); const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban'; if (memberUid) { - memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin || ''; + memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin ?? ''; } else { memberUin = '0'; // 0表示全员禁言 if (duration > 0) { @@ -225,7 +225,7 @@ export class OneBotGroupApi { const memberUin = member?.uin; const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid); if (memberUin) { - const operatorUin = adminMember?.uin || memberUin; + const operatorUin = adminMember?.uin ?? memberUin; return new OB11GroupIncreaseEvent( this.core, parseInt(GroupCode), @@ -240,7 +240,7 @@ export class OneBotGroupApi { async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) { const groupElement = grayTipElement?.groupElement; if (!groupElement) return undefined; - const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin || (await this.core.apis.UserApi.getUidByUinV2(groupElement.adminUid)); + const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin ?? (await this.core.apis.UserApi.getUidByUinV2(groupElement.adminUid)); if (adminUin) { return new OB11GroupDecreaseEvent( this.core, diff --git a/src/onebot/event/meta/OB11HeartbeatEvent.ts b/src/onebot/event/meta/OB11HeartbeatEvent.ts index 41d16ba9..7171d9cc 100644 --- a/src/onebot/event/meta/OB11HeartbeatEvent.ts +++ b/src/onebot/event/meta/OB11HeartbeatEvent.ts @@ -11,11 +11,11 @@ export class OB11HeartbeatEvent extends OB11BaseMetaEvent { status: HeartbeatStatus; interval: number; - public constructor(core: NapCatCore, interval: number, isOnline: boolean | undefined, isGood: boolean) { + public constructor(core: NapCatCore, interval: number, isOnline: boolean, isGood: boolean) { super(core); this.interval = interval; this.status = { - online: isOnline && true, + online: isOnline, good: isGood, }; } diff --git a/src/onebot/event/notice/OB11PokeEvent.ts b/src/onebot/event/notice/OB11PokeEvent.ts index adf44da9..80a2e760 100644 --- a/src/onebot/event/notice/OB11PokeEvent.ts +++ b/src/onebot/event/notice/OB11PokeEvent.ts @@ -25,7 +25,7 @@ export class OB11GroupPokeEvent extends OB11PokeEvent { raw_info: any; //raw_message nb等框架标准为string - constructor(core: NapCatCore, group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) { + constructor(core: NapCatCore, group_id: number, user_id: number, target_id: number, raw_message: any) { super(core); this.group_id = group_id; this.target_id = target_id; diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 1cd65819..90c33bcb 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -6,7 +6,6 @@ import { GroupNotifyMsgStatus, GroupNotifyMsgType, InstanceContext, - MsgSourceType, NapCatCore, NodeIKernelBuddyListener, NodeIKernelGroupListener, @@ -269,10 +268,8 @@ export class NapCatOneBot11Adapter { }, m.msgId, ); - // if (m.sourceType == MsgSourceType.K_DOWN_SOURCETYPE_AIOINNER) { await this.emitMsg(m) .catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e)); - // } } }; @@ -504,10 +501,9 @@ export class NapCatOneBot11Adapter { this.context.logger.logDebug('转化为 OB11Message', ob11Msg); if (debug) { ob11Msg.raw = message; - } else { - if (ob11Msg.message.length === 0) { - return; - } + } else if (ob11Msg.message.length === 0) { + return; + } const isSelfMsg = ob11Msg.user_id.toString() == this.core.selfInfo.uin; if (isSelfMsg && !reportSelfMessage) { diff --git a/src/onebot/network/active-websocket.ts b/src/onebot/network/active-websocket.ts index e35c16c5..a8cf1bd2 100644 --- a/src/onebot/network/active-websocket.ts +++ b/src/onebot/network/active-websocket.ts @@ -37,7 +37,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } this.heartbeatRef = setInterval(() => { if (this.connection && this.connection.readyState === WebSocket.OPEN) { - this.connection.send(JSON.stringify(new OB11HeartbeatEvent(this.core, this.heartbeatIntervalInMillis, this.core.selfInfo.online, true))); + this.connection.send(JSON.stringify(new OB11HeartbeatEvent(this.core, this.heartbeatIntervalInMillis, this.core.selfInfo.online ?? true, true))); } }, this.heartbeatIntervalInMillis); await this.tryConnect(); @@ -148,7 +148,6 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { return; } const retdata = await action.websocketHandle(receiveData.params, echo ?? ''); - const packet = Object.assign({}, retdata); - this.checkStateAndReply(packet); + this.checkStateAndReply({ ...retdata }); } } diff --git a/src/onebot/network/passive-websocket.ts b/src/onebot/network/passive-websocket.ts index ea18ebd8..e4a8f597 100644 --- a/src/onebot/network/passive-websocket.ts +++ b/src/onebot/network/passive-websocket.ts @@ -145,7 +145,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter { this.wsClientsMutex.runExclusive(async () => { this.wsClientWithEvent.forEach((wsClient) => { if (wsClient.readyState === WebSocket.OPEN) { - wsClient.send(JSON.stringify(new OB11HeartbeatEvent(this.core, this.heartbeatInterval, this.core.selfInfo.online, true))); + wsClient.send(JSON.stringify(new OB11HeartbeatEvent(this.core, this.heartbeatInterval, this.core.selfInfo.online ?? true, true))); } }); }); @@ -189,8 +189,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter { return; } const retdata = await action.websocketHandle(receiveData.params, echo ?? ''); - const packet = Object.assign({}, retdata); - this.checkStateAndReply(packet, wsClient); + this.checkStateAndReply({ ...retdata }, wsClient); } } diff --git a/vite.config.ts b/vite.config.ts index 794278d3..8202159f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,12 +11,8 @@ function genCpModule(module: string) { } let startScripts: string[] | undefined = undefined; if (process.env.NAPCAT_BUILDSYS == 'linux') { - if (process.env.NAPCAT_BUILDARCH == 'x64') { - } startScripts = []; } else if (process.env.NAPCAT_BUILDSYS == 'win32') { - if (process.env.NAPCAT_BUILDARCH == 'x64') { - } startScripts = ['./script/KillQQ.bat']; } else { startScripts = ['./script/KillQQ.bat'];