mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: webui reload
This commit is contained in:
@@ -195,6 +195,16 @@ export class NapCatOneBot11Adapter {
|
|||||||
nowConfig: NetworkConfigAdapter[],
|
nowConfig: NetworkConfigAdapter[],
|
||||||
adapterClass: new (...args: any[]) => IOB11NetworkAdapter
|
adapterClass: new (...args: any[]) => IOB11NetworkAdapter
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// 比较旧的在新的找不到的回收
|
||||||
|
for (const adapterConfig of prevConfig) {
|
||||||
|
const existingAdapter = nowConfig.find((e) => e.name === adapterConfig.name);
|
||||||
|
if (!existingAdapter) {
|
||||||
|
const existingAdapter = this.networkManager.findSomeAdapter(adapterConfig.name);
|
||||||
|
if (existingAdapter) {
|
||||||
|
await this.networkManager.closeSomeAdaterWhenOpen([existingAdapter]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 通知新配置重载 删除关闭的 加入新开的
|
// 通知新配置重载 删除关闭的 加入新开的
|
||||||
for (const adapterConfig of nowConfig) {
|
for (const adapterConfig of nowConfig) {
|
||||||
const existingAdapter = this.networkManager.findSomeAdapter(adapterConfig.name);
|
const existingAdapter = this.networkManager.findSomeAdapter(adapterConfig.name);
|
||||||
@@ -203,21 +213,11 @@ export class NapCatOneBot11Adapter {
|
|||||||
if (networkChange === OB11NetworkReloadType.NetWorkClose) {
|
if (networkChange === OB11NetworkReloadType.NetWorkClose) {
|
||||||
await this.networkManager.closeSomeAdaterWhenOpen([existingAdapter]);
|
await this.networkManager.closeSomeAdaterWhenOpen([existingAdapter]);
|
||||||
}
|
}
|
||||||
} else {
|
} else if(adapterConfig.enable) {
|
||||||
const newAdapter = new adapterClass(adapterConfig.name, adapterConfig, this.core, this.actions);
|
const newAdapter = new adapterClass(adapterConfig.name, adapterConfig, this.core, this.actions);
|
||||||
await this.networkManager.registerAdapterAndOpen(newAdapter);
|
await this.networkManager.registerAdapterAndOpen(newAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 比较旧的找不到的回收
|
|
||||||
for (const adapterConfig of prevConfig) {
|
|
||||||
const existingAdapter = nowConfig.find((e) => e.name === adapterConfig.name);
|
|
||||||
if (!existingAdapter) {
|
|
||||||
const existingAdapter = this.networkManager.findSomeAdapter(adapterConfig.name);
|
|
||||||
if (existingAdapter) {
|
|
||||||
await this.networkManager.closeSomeAdaterWhenOpen([existingAdapter]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private initMsgListener() {
|
private initMsgListener() {
|
||||||
@@ -407,103 +407,103 @@ export class NapCatOneBot11Adapter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
// if (
|
// if (
|
||||||
// notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN ||
|
// notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN ||
|
||||||
// notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN
|
// notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN
|
||||||
// ) {
|
// ) {
|
||||||
// this.context.logger.logDebug('有成员退出通知', notify);
|
// this.context.logger.logDebug('有成员退出通知', notify);
|
||||||
// const member1Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
// const member1Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
||||||
// let operatorId = member1Uin;
|
// let operatorId = member1Uin;
|
||||||
// let subType: GroupDecreaseSubType = 'leave';
|
// let subType: GroupDecreaseSubType = 'leave';
|
||||||
// if (notify.user2.uid) {
|
// if (notify.user2.uid) {
|
||||||
// // 是被踢的
|
// // 是被踢的
|
||||||
// const member2Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid);
|
// const member2Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid);
|
||||||
// if (member2Uin) {
|
// if (member2Uin) {
|
||||||
// operatorId = member2Uin;
|
// operatorId = member2Uin;
|
||||||
// }
|
// }
|
||||||
// subType = 'kick';
|
// subType = 'kick';
|
||||||
// }
|
// }
|
||||||
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(
|
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(
|
||||||
// this.core,
|
// this.core,
|
||||||
// parseInt(notify.group.groupCode),
|
// parseInt(notify.group.groupCode),
|
||||||
// parseInt(member1Uin),
|
// parseInt(member1Uin),
|
||||||
// parseInt(operatorId),
|
// parseInt(operatorId),
|
||||||
// subType
|
// subType
|
||||||
// );
|
// );
|
||||||
// this.networkManager
|
// this.networkManager
|
||||||
// .emitEvent(groupDecreaseEvent)
|
// .emitEvent(groupDecreaseEvent)
|
||||||
// .catch((e) =>
|
// .catch((e) =>
|
||||||
// this.context.logger.logError.bind(this.context.logger)('处理群成员退出失败', e)
|
// this.context.logger.logError.bind(this.context.logger)('处理群成员退出失败', e)
|
||||||
// );
|
// );
|
||||||
// // notify.status == 1 表示未处理 2表示处理完成
|
// // notify.status == 1 表示未处理 2表示处理完成
|
||||||
// } else
|
// } else
|
||||||
if (
|
if (
|
||||||
[GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS].includes(notify.type) &&
|
[GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS].includes(notify.type) &&
|
||||||
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
||||||
) {
|
) {
|
||||||
this.context.logger.logDebug('有加群请求');
|
this.context.logger.logDebug('有加群请求');
|
||||||
try {
|
try {
|
||||||
let requestUin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
let requestUin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
||||||
if (isNaN(parseInt(requestUin))) {
|
if (isNaN(parseInt(requestUin))) {
|
||||||
requestUin = (await this.core.apis.UserApi.getUserDetailInfo(notify.user1.uid)).uin;
|
requestUin = (await this.core.apis.UserApi.getUserDetailInfo(notify.user1.uid)).uin;
|
||||||
|
}
|
||||||
|
const groupRequestEvent = new OB11GroupRequestEvent(
|
||||||
|
this.core,
|
||||||
|
parseInt(notify.group.groupCode),
|
||||||
|
parseInt(requestUin),
|
||||||
|
'add',
|
||||||
|
notify.postscript,
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
this.networkManager
|
||||||
|
.emitEvent(groupRequestEvent)
|
||||||
|
.catch((e) =>
|
||||||
|
this.context.logger.logError.bind(this.context.logger)('处理加群请求失败', e)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
this.context.logger.logError.bind(this.context.logger)(
|
||||||
|
'获取加群人QQ号失败 Uid:',
|
||||||
|
notify.user1.uid,
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const groupRequestEvent = new OB11GroupRequestEvent(
|
} else if (
|
||||||
|
notify.type == GroupNotifyMsgType.INVITED_BY_MEMBER &&
|
||||||
|
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
||||||
|
) {
|
||||||
|
this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
|
||||||
|
const groupInviteEvent = new OB11GroupRequestEvent(
|
||||||
this.core,
|
this.core,
|
||||||
parseInt(notify.group.groupCode),
|
parseInt(notify.group.groupCode),
|
||||||
parseInt(requestUin),
|
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid)),
|
||||||
|
'invite',
|
||||||
|
notify.postscript,
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
this.networkManager
|
||||||
|
.emitEvent(groupInviteEvent)
|
||||||
|
.catch((e) =>
|
||||||
|
this.context.logger.logError.bind(this.context.logger)('处理邀请本人加群失败', e)
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
notify.type == GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS &&
|
||||||
|
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
||||||
|
) {
|
||||||
|
this.context.logger.logDebug(`收到群员邀请加群通知:${notify}`);
|
||||||
|
const groupInviteEvent = new OB11GroupRequestEvent(
|
||||||
|
this.core,
|
||||||
|
parseInt(notify.group.groupCode),
|
||||||
|
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid)),
|
||||||
'add',
|
'add',
|
||||||
notify.postscript,
|
notify.postscript,
|
||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
this.networkManager
|
this.networkManager
|
||||||
.emitEvent(groupRequestEvent)
|
.emitEvent(groupInviteEvent)
|
||||||
.catch((e) =>
|
.catch((e) =>
|
||||||
this.context.logger.logError.bind(this.context.logger)('处理加群请求失败', e)
|
this.context.logger.logError.bind(this.context.logger)('处理邀请本人加群失败', e)
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
this.context.logger.logError.bind(this.context.logger)(
|
|
||||||
'获取加群人QQ号失败 Uid:',
|
|
||||||
notify.user1.uid,
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if (
|
|
||||||
notify.type == GroupNotifyMsgType.INVITED_BY_MEMBER &&
|
|
||||||
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
|
||||||
) {
|
|
||||||
this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
|
|
||||||
const groupInviteEvent = new OB11GroupRequestEvent(
|
|
||||||
this.core,
|
|
||||||
parseInt(notify.group.groupCode),
|
|
||||||
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid)),
|
|
||||||
'invite',
|
|
||||||
notify.postscript,
|
|
||||||
flag
|
|
||||||
);
|
|
||||||
this.networkManager
|
|
||||||
.emitEvent(groupInviteEvent)
|
|
||||||
.catch((e) =>
|
|
||||||
this.context.logger.logError.bind(this.context.logger)('处理邀请本人加群失败', e)
|
|
||||||
);
|
|
||||||
} else if (
|
|
||||||
notify.type == GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS &&
|
|
||||||
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
|
||||||
) {
|
|
||||||
this.context.logger.logDebug(`收到群员邀请加群通知:${notify}`);
|
|
||||||
const groupInviteEvent = new OB11GroupRequestEvent(
|
|
||||||
this.core,
|
|
||||||
parseInt(notify.group.groupCode),
|
|
||||||
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid)),
|
|
||||||
'add',
|
|
||||||
notify.postscript,
|
|
||||||
flag
|
|
||||||
);
|
|
||||||
this.networkManager
|
|
||||||
.emitEvent(groupInviteEvent)
|
|
||||||
.catch((e) =>
|
|
||||||
this.context.logger.logError.bind(this.context.logger)('处理邀请本人加群失败', e)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user