using System.Text.Json;
using RoBot.Start.ConstValue;
using RoBot.Start.Dto.ConfigDto;
namespace RoBot.Start.RoBotConfig
{
public class RoBotsConfig
{
///
/// 获取配置信息
///
///
public static async Task GetConfig()
{
ConfigSetting config = new();
if (File.Exists(Consts.Config))
{
var config_json = await File.ReadAllTextAsync(Consts.Config);
config = JsonSerializer.Deserialize(config_json) ?? config;
}
else
{
var config_json = JsonSerializer.Serialize(config);
await File.WriteAllTextAsync(Consts.Config, config_json);
}
return config;
}
}
}