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