mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
fix[config]support overwrite by user
This commit is contained in:
parent
03bc844ad0
commit
28927f950d
@ -73,8 +73,12 @@ export class ConfigBase<T> {
|
||||
}
|
||||
}
|
||||
|
||||
save(config: T) {
|
||||
save(config: T, overwrite: boolean = false) {
|
||||
Object.assign(this, config);
|
||||
if (overwrite) {
|
||||
// 用户要求强制写入,则变更当前文件为目标文件
|
||||
this.pathName = `${selfInfo.uin}`
|
||||
}
|
||||
const configPath = this.getConfigPath(this.pathName);
|
||||
try {
|
||||
fs.writeFileSync(configPath, JSON.stringify(this, this.getKeys(), 2));
|
||||
|
@ -15,6 +15,6 @@ export class SetConfigAction extends BaseAction<OB11Config, void> {
|
||||
actionName = ActionName.SetConfig;
|
||||
|
||||
protected async _handle(payload: OB11Config): Promise<void> {
|
||||
ob11Config.save(payload);
|
||||
ob11Config.save(payload, true);
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ export class NapCatOnebot11 {
|
||||
// throw new Error('Invalid configuration object');
|
||||
// }
|
||||
const OldConfig = JSON.parse(JSON.stringify(ob11Config)); //进行深拷贝
|
||||
ob11Config.save(NewOb11);//保存新配置
|
||||
ob11Config.save(NewOb11, true);//保存新配置
|
||||
|
||||
const isHttpChanged = !isEqual(NewOb11.http.port, OldConfig.http.port);
|
||||
const isHttpEnableChanged = !isEqual(NewOb11.http.enable, OldConfig.http.enable);
|
||||
@ -500,7 +500,7 @@ export class NapCatOnebot11 {
|
||||
groupRequestEvent.flag = flag;
|
||||
postOB11Event(groupRequestEvent);
|
||||
} else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
||||
logDebug('收到邀请我加群通知');
|
||||
logDebug(`收到邀请我加群通知:${notify}`);
|
||||
const groupInviteEvent = new OB11GroupRequestEvent();
|
||||
groupInviteEvent.group_id = parseInt(notify.group.groupCode);
|
||||
const user_id = (await NTQQUserApi.getUinByUid(notify.user2.uid)) || '';
|
||||
|
Loading…
Reference in New Issue
Block a user