Fixed DeviceInfo Generation for Lagrange.OneBot

This commit is contained in:
Linwenxuan 2023-10-14 23:10:06 +08:00
parent bfd93a84e0
commit 64a0c41add

View file

@ -59,13 +59,13 @@ public sealed class LagrangeAppBuilder
BotDeviceInfo deviceInfo; BotDeviceInfo deviceInfo;
if (!File.Exists(deviceInfoPath)) if (!File.Exists(deviceInfoPath))
{ {
deviceInfo = new BotDeviceInfo(); deviceInfo = BotDeviceInfo.GenerateInfo();
string json = JsonSerializer.Serialize(deviceInfo); string json = JsonSerializer.Serialize(deviceInfo);
File.WriteAllText(deviceInfoPath, json); File.WriteAllText(deviceInfoPath, json);
} }
else else
{ {
deviceInfo = JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText(deviceInfoPath)) ?? new BotDeviceInfo(); deviceInfo = JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText(deviceInfoPath)) ?? BotDeviceInfo.GenerateInfo();
} }
Services.AddSingleton(BotFactory.Create(config, deviceInfo, keystore)); Services.AddSingleton(BotFactory.Create(config, deviceInfo, keystore));