Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 89c4c17

Browse files
authored
[Core] fix one-time login (#719)
1 parent d00c8da commit 89c4c17

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Lagrange.OneBot/Core/Login/LoginService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Text.Json;
12
using Lagrange.Core;
23
using Lagrange.Core.Common.Interface.Api;
34
using Lagrange.Core.Event.EventArg;
@@ -57,6 +58,9 @@ public async Task StartAsync(CancellationToken token)
5758

5859
if (!isSucceed) throw new Exception("All login failed!");
5960

61+
string keystoreJson = JsonSerializer.Serialize(_lagrange.UpdateKeystore());
62+
File.WriteAllText(configuration["ConfigPath:Keystore"] ?? "keystore.json", keystoreJson);
63+
6064
_logger.LogInformation("Bot Uin: {}", _lagrange.BotUin);
6165

6266
await _web.StartAsync(token);

Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ public static HostApplicationBuilder ConfigureLagrangeCore(this HostApplicationB
4848
var configuration = services.GetRequiredService<IConfiguration>();
4949
string path = configuration["ConfigPath:DeviceInfo"] ?? "device.json";
5050

51-
return File.Exists(path)
51+
var device = File.Exists(path)
5252
? JsonSerializer.Deserialize<BotDeviceInfo>(File.ReadAllText(path)) ?? BotDeviceInfo.GenerateInfo()
5353
: BotDeviceInfo.GenerateInfo();
54+
55+
string deviceJson = JsonSerializer.Serialize(device);
56+
File.WriteAllText(path, deviceJson);
57+
58+
return device;
5459
})
5560
.AddSingleton((services) => // Keystore
5661
{

0 commit comments

Comments
 (0)