submodule对gitea不管用,所以直接拉了一份拉格兰

This commit is contained in:
2025-02-04 16:29:43 +08:00
parent b0bfc803e3
commit d149a2ea0f
1023 changed files with 43308 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ using Lagrange.Core;
using Lagrange.Core.Common;
using Lagrange.Core.Common.Interface;
using Lagrange.Core.Common.Interface.Api;
using Lagrange.Core.Message;
using Shrink.Logger;
using Shrink.Utility;
using Console = System.Console;
@@ -59,14 +60,15 @@ public class BotService
};
// bot信息保存
Client.Invoker.OnBotOnlineEvent += (_, @event) =>
Client.Invoker.OnBotOnlineEvent += async (_, @event) =>
{
Console.WriteLine(@event.ToString());
_isOnline = true;
server.Start();
Console.WriteLine($"[{DateTime.Now}] [gRPC Server] [Info]: Listening on port: {port}");
/*LogManager.Instance.LogChain.LogMessage($"{DateTime.Now}", "LoginEvent", LogLevel.Info, MsgType.Public,
620902312, "Login");*/
await Task.Delay(1000);
LogManager.Instance.LogChain.LogMessage($"{DateTime.Now}", "LoginEvent", LogLevel.Info, MsgType.Public,
620902312, "Login");
};
Client.Invoker.OnBotOfflineEvent += async (_, @event) =>
{
@@ -74,22 +76,25 @@ public class BotService
await server.ShutdownAsync();
_isOnline = false;
};
if (File.Exists(KeystoreFilePath))
Client.Invoker.OnBotCaptchaEvent += (_, @event) =>
{
await Client.LoginByPassword();
if (!_isOnline)
Console.WriteLine(@event.ToString());
var captcha = Console.ReadLine();
var randStr = Console.ReadLine();
if (captcha != null && randStr != null) Client.SubmitCaptcha(captcha, randStr);
};
await Client.LoginByPassword();
if (!_isOnline)
{
Console.WriteLine("账密登录失败,请尝试二维码登录。");
var qrCode = await Client.FetchQrCode();
if (qrCode != null)
{
Console.WriteLine("账密登录失败,请尝试二维码登录。");
var qrCode = await Client.FetchQrCode();
if (qrCode != null)
{
await File.WriteAllBytesAsync("qr.png", qrCode.Value.QrCode);
await Client.LoginByQrCode();
}
await File.WriteAllBytesAsync("qr.png", qrCode.Value.QrCode);
await Client.LoginByQrCode();
}
}
await File.WriteAllTextAsync(KeystoreFilePath, JsonSerializer.Serialize(Client.UpdateKeystore()));
await File.WriteAllTextAsync(DeviceInfoFilePath, JsonSerializer.Serialize(Client.UpdateDeviceInfo()));
}