Skip to content

Commit

Permalink
Save BotDeviceInfo to directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 14, 2023
1 parent 20c633e commit a09d94f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Lagrange.OneBot/LagrangeAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ public LagrangeAppBuilder ConfigureBots()
keystore = JsonSerializer.Deserialize<BotKeystore>(File.ReadAllText(keystorePath)) ?? new BotKeystore();
}

var deviceInfo = !File.Exists(deviceInfoPath)
? new BotDeviceInfo()
: JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText(deviceInfoPath)) ?? new BotDeviceInfo();
BotDeviceInfo deviceInfo;
if (!File.Exists(deviceInfoPath))
{
deviceInfo = new BotDeviceInfo();
string json = JsonSerializer.Serialize(deviceInfo);
File.WriteAllText(deviceInfoPath, json);
}
else
{
deviceInfo = JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText(deviceInfoPath)) ?? new BotDeviceInfo();
}

Services.AddSingleton(BotFactory.Create(config, deviceInfo, keystore));

Expand Down

0 comments on commit a09d94f

Please sign in to comment.