@@ -1,43 +0,0 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using Lagrange.Core.Common;
|
|
||||||
|
|
||||||
namespace Shrink.Utility;
|
|
||||||
|
|
||||||
public static class Data
|
|
||||||
{
|
|
||||||
public static void SaveKeystore(BotKeystore keystore) =>
|
|
||||||
File.WriteAllText("Keystore.json", JsonSerializer.Serialize(keystore));
|
|
||||||
|
|
||||||
public static BotDeviceInfo GetDeviceInfo()
|
|
||||||
{
|
|
||||||
if (File.Exists("DeviceInfo.json"))
|
|
||||||
{
|
|
||||||
var info = JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText("DeviceInfo.json"));
|
|
||||||
if (info != null) return info;
|
|
||||||
|
|
||||||
info = BotDeviceInfo.GenerateInfo();
|
|
||||||
File.WriteAllText("DeviceInfo.json", JsonSerializer.Serialize(info));
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
var deviceInfo = BotDeviceInfo.GenerateInfo();
|
|
||||||
File.WriteAllText("DeviceInfo.json", JsonSerializer.Serialize(deviceInfo));
|
|
||||||
return deviceInfo;
|
|
||||||
}
|
|
||||||
public static BotKeystore? LoadKeystore()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var text = File.ReadAllText("Keystore.json");
|
|
||||||
return JsonSerializer.Deserialize<BotKeystore>(text, new JsonSerializerOptions()
|
|
||||||
{
|
|
||||||
ReferenceHandler = ReferenceHandler.Preserve
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user