首次提交

This commit is contained in:
LyMysterious
2025-05-29 18:18:30 +08:00
parent 1bec8de500
commit 0712d3a6d2
1057 changed files with 44596 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
using System.Text.Json;
using Lagrange.Core.Common;
using RoBot.Start.ConstValue;
namespace RoBot.Start.Keystore
{
/// <summary>
/// 账号登录信息
/// </summary>
public class KeystoreConfig
{
/// <summary>
/// 获取账号登录信息
/// </summary>
/// <returns></returns>
public static async Task<KeystoreInfo> GetBotKeystore()
{
KeystoreInfo result = new()
{
ReLogin = false
};
var botKeystore = File.Exists(Consts.KeystoreConfig)
? JsonSerializer.Deserialize<BotKeystore>(await File.ReadAllTextAsync(Consts.KeystoreConfig)) ?? new()
: new();
result.BotKeystore = botKeystore;
if (botKeystore.Session.TempPassword?.Length > 0)
{
result.ReLogin = true;
}
return result;
}
/// <summary>
/// 保存登录信息
/// </summary>
/// <param name="botKeystore"></param>
/// <returns></returns>
public static async Task SaveBotKeystore(BotKeystore botKeystore)
{
string keystoreJson = JsonSerializer.Serialize(botKeystore);
await File.WriteAllTextAsync(Consts.KeystoreConfig, keystoreJson);
}
}
public class KeystoreInfo
{
/// <summary>
/// BotKeystore
/// </summary>
public BotKeystore BotKeystore { get; set; }
/// <summary>
/// 是否需要重新登录
/// </summary>
public bool ReLogin { get; set; }
}
}