修复无法自动登录的bug

This commit is contained in:
2024-12-19 21:30:03 +08:00
parent 2b7632344e
commit 4e7c846426
3 changed files with 138 additions and 168 deletions

View File

@@ -1,8 +1,4 @@
using Debugger;
using Grpc.Core;
using Shrink.API;
using Shrink.Command;
using Shrink.Login;
using BotService = Shrink.Login.BotService;
namespace Shrink;
@@ -10,62 +6,6 @@ public static class Program
{
public static async Task Main()
{
/*var originalAssemblyPath = "Lagrange.Core.dll";
var tempAssemblyPath = "ModifiedExternalAssembly.dll";
var oldUrl = "自己找";
var newUrl = "自己找";
ModifyAssembly(originalAssemblyPath, tempAssemblyPath, oldUrl, newUrl);*/
const int port = 50051;
var server = new Server
{
Services = { BotService.BindService(new BotServiceImpl()) },
Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine($"gRPC server listening on port {port}");
await QrCode.Instance.Login();
await Commands.Instance.Init();
await Commands.Instance.Run();
//await server.ShutdownAsync();
await BotService.Instance.Login();
}
/*private static void ModifyAssembly(string originalAssemblyPath, string tempAssemblyPath, string oldUrl, string newUrl)
{
var assembly = AssemblyDefinition.ReadAssembly(originalAssemblyPath);
var module = assembly.MainModule;
// 查找LinuxSigner类型
var linuxSignerType = module.Types.FirstOrDefault(t => t.Name == "LinuxSigner");
if (linuxSignerType == null)
{
Console.WriteLine("无LinuxSigner类型");
return;
}
// 查找构造函数
var constructor = linuxSignerType.Methods.FirstOrDefault(m => m.IsConstructor);
if (constructor == null)
{
Console.WriteLine("无构造函数");
return;
}
var ilProcessor = constructor.Body.GetILProcessor();
foreach (var instruction in constructor.Body.Instructions)
{
// 检查是否是加载字符串操作
if (instruction.OpCode == OpCodes.Ldstr && instruction.Operand is string str && str == oldUrl)
{
instruction.Operand = newUrl; // 替换为新URL
Console.WriteLine($"替换: {oldUrl}为{newUrl}");
}
}
assembly.Write(tempAssemblyPath);
Console.WriteLine($"已将修改后的程序集保存在{tempAssemblyPath}");
}*/
}