mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: 代码精简
This commit is contained in:
parent
4cf52e1b13
commit
037065291d
@ -194,7 +194,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 开始转换 ${stringifyWithBigInt(packetMsgElements)}`);
|
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 开始转换 ${stringifyWithBigInt(packetMsgElements)}`);
|
||||||
const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgWithSendMsgToPacketMsg(packetMsgElements);
|
const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgWithSendMsgToPacketMsg(packetMsgElements);
|
||||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
||||||
packetMsg.push(transformedMsg!);
|
packetMsg.push(transformedMsg);
|
||||||
} else if (node.data.id) {
|
} else if (node.data.id) {
|
||||||
const id = node.data.id;
|
const id = node.data.id;
|
||||||
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(+id) || MessageUnique.getPeerByMsgId(id);
|
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(+id) || MessageUnique.getPeerByMsgId(id);
|
||||||
@ -207,7 +207,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
await this.core.apis.FileApi.downloadRawMsgMedia([msg]);
|
await this.core.apis.FileApi.downloadRawMsgMedia([msg]);
|
||||||
const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgToPacketMsg(msg, msgPeer);
|
const transformedMsg = this.core.apis.PacketApi.pkt.msgConverter.rawMsgToPacketMsg(msg, msgPeer);
|
||||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
||||||
packetMsg.push(transformedMsg!);
|
packetMsg.push(transformedMsg);
|
||||||
} else {
|
} else {
|
||||||
logger.logDebug(`handleForwardedNodesPacket 跳过元素 ${stringifyWithBigInt(node)}`);
|
logger.logDebug(`handleForwardedNodesPacket 跳过元素 ${stringifyWithBigInt(node)}`);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ export class OneBotGroupApi {
|
|||||||
let duration = parseInt(groupElement.shutUp!.duration);
|
let duration = parseInt(groupElement.shutUp!.duration);
|
||||||
const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban';
|
const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban';
|
||||||
if (memberUid) {
|
if (memberUid) {
|
||||||
memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin || '';
|
memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin ?? '';
|
||||||
} else {
|
} else {
|
||||||
memberUin = '0'; // 0表示全员禁言
|
memberUin = '0'; // 0表示全员禁言
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
@ -225,7 +225,7 @@ export class OneBotGroupApi {
|
|||||||
const memberUin = member?.uin;
|
const memberUin = member?.uin;
|
||||||
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
||||||
if (memberUin) {
|
if (memberUin) {
|
||||||
const operatorUin = adminMember?.uin || memberUin;
|
const operatorUin = adminMember?.uin ?? memberUin;
|
||||||
return new OB11GroupIncreaseEvent(
|
return new OB11GroupIncreaseEvent(
|
||||||
this.core,
|
this.core,
|
||||||
parseInt(GroupCode),
|
parseInt(GroupCode),
|
||||||
@ -240,7 +240,7 @@ export class OneBotGroupApi {
|
|||||||
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const groupElement = grayTipElement?.groupElement;
|
const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
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) {
|
if (adminUin) {
|
||||||
return new OB11GroupDecreaseEvent(
|
return new OB11GroupDecreaseEvent(
|
||||||
this.core,
|
this.core,
|
||||||
|
@ -11,11 +11,11 @@ export class OB11HeartbeatEvent extends OB11BaseMetaEvent {
|
|||||||
status: HeartbeatStatus;
|
status: HeartbeatStatus;
|
||||||
interval: number;
|
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);
|
super(core);
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.status = {
|
this.status = {
|
||||||
online: isOnline && true,
|
online: isOnline,
|
||||||
good: isGood,
|
good: isGood,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export class OB11GroupPokeEvent extends OB11PokeEvent {
|
|||||||
raw_info: any;
|
raw_info: any;
|
||||||
|
|
||||||
//raw_message nb等框架标准为string
|
//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);
|
super(core);
|
||||||
this.group_id = group_id;
|
this.group_id = group_id;
|
||||||
this.target_id = target_id;
|
this.target_id = target_id;
|
||||||
|
@ -6,7 +6,6 @@ import {
|
|||||||
GroupNotifyMsgStatus,
|
GroupNotifyMsgStatus,
|
||||||
GroupNotifyMsgType,
|
GroupNotifyMsgType,
|
||||||
InstanceContext,
|
InstanceContext,
|
||||||
MsgSourceType,
|
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
NodeIKernelBuddyListener,
|
NodeIKernelBuddyListener,
|
||||||
NodeIKernelGroupListener,
|
NodeIKernelGroupListener,
|
||||||
@ -269,10 +268,8 @@ export class NapCatOneBot11Adapter {
|
|||||||
},
|
},
|
||||||
m.msgId,
|
m.msgId,
|
||||||
);
|
);
|
||||||
// if (m.sourceType == MsgSourceType.K_DOWN_SOURCETYPE_AIOINNER) {
|
|
||||||
await this.emitMsg(m)
|
await this.emitMsg(m)
|
||||||
.catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
|
.catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -504,10 +501,9 @@ export class NapCatOneBot11Adapter {
|
|||||||
this.context.logger.logDebug('转化为 OB11Message', ob11Msg);
|
this.context.logger.logDebug('转化为 OB11Message', ob11Msg);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
ob11Msg.raw = message;
|
ob11Msg.raw = message;
|
||||||
} else {
|
} else if (ob11Msg.message.length === 0) {
|
||||||
if (ob11Msg.message.length === 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const isSelfMsg = ob11Msg.user_id.toString() == this.core.selfInfo.uin;
|
const isSelfMsg = ob11Msg.user_id.toString() == this.core.selfInfo.uin;
|
||||||
if (isSelfMsg && !reportSelfMessage) {
|
if (isSelfMsg && !reportSelfMessage) {
|
||||||
|
@ -37,7 +37,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
}
|
}
|
||||||
this.heartbeatRef = setInterval(() => {
|
this.heartbeatRef = setInterval(() => {
|
||||||
if (this.connection && this.connection.readyState === WebSocket.OPEN) {
|
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);
|
}, this.heartbeatIntervalInMillis);
|
||||||
await this.tryConnect();
|
await this.tryConnect();
|
||||||
@ -148,7 +148,6 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const retdata = await action.websocketHandle(receiveData.params, echo ?? '');
|
const retdata = await action.websocketHandle(receiveData.params, echo ?? '');
|
||||||
const packet = Object.assign({}, retdata);
|
this.checkStateAndReply<any>({ ...retdata });
|
||||||
this.checkStateAndReply<any>(packet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
this.wsClientsMutex.runExclusive(async () => {
|
this.wsClientsMutex.runExclusive(async () => {
|
||||||
this.wsClientWithEvent.forEach((wsClient) => {
|
this.wsClientWithEvent.forEach((wsClient) => {
|
||||||
if (wsClient.readyState === WebSocket.OPEN) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const retdata = await action.websocketHandle(receiveData.params, echo ?? '');
|
const retdata = await action.websocketHandle(receiveData.params, echo ?? '');
|
||||||
const packet = Object.assign({}, retdata);
|
this.checkStateAndReply<any>({ ...retdata }, wsClient);
|
||||||
this.checkStateAndReply<any>(packet, wsClient);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,8 @@ function genCpModule(module: string) {
|
|||||||
}
|
}
|
||||||
let startScripts: string[] | undefined = undefined;
|
let startScripts: string[] | undefined = undefined;
|
||||||
if (process.env.NAPCAT_BUILDSYS == 'linux') {
|
if (process.env.NAPCAT_BUILDSYS == 'linux') {
|
||||||
if (process.env.NAPCAT_BUILDARCH == 'x64') {
|
|
||||||
}
|
|
||||||
startScripts = [];
|
startScripts = [];
|
||||||
} else if (process.env.NAPCAT_BUILDSYS == 'win32') {
|
} else if (process.env.NAPCAT_BUILDSYS == 'win32') {
|
||||||
if (process.env.NAPCAT_BUILDARCH == 'x64') {
|
|
||||||
}
|
|
||||||
startScripts = ['./script/KillQQ.bat'];
|
startScripts = ['./script/KillQQ.bat'];
|
||||||
} else {
|
} else {
|
||||||
startScripts = ['./script/KillQQ.bat'];
|
startScripts = ['./script/KillQQ.bat'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user