Skip to content

Commit

Permalink
all tires failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Deliay committed Apr 25, 2024
1 parent 722afa0 commit 934fcbc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
37 changes: 25 additions & 12 deletions Mikibot.Analyze/MiraiHttp/LagrangeBotBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private static async ValueTask<BotDeviceInfo> GetDeviceInfo()
info.DeviceName = "Generic x86 System";
info.KernelVersion = "6.6.7-arch1-1";
info.SystemKernel = "Linux";

await using var file = File.OpenWrite(BotDeviceStore);
await JsonSerializer.SerializeAsync(file, info);

Expand Down Expand Up @@ -89,9 +90,30 @@ void InvokerOnOnBotOnlineEvent(BotContext context, BotOnlineEvent @event)
public async ValueTask Run()
{
var botKeystore = await GetKeyStore();
bot = BotFactory.Create(new BotConfig()
{
Protocol = Protocols.Linux,
}, await GetDeviceInfo(), new BotKeystore());
bot.Invoker.OnBotLogEvent += (_, args) => botLogger.Log(args.Level switch
{
LogLevel.Debug => Microsoft.Extensions.Logging.LogLevel.Trace,
LogLevel.Verbose => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Information => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Warning => Microsoft.Extensions.Logging.LogLevel.Warning,
LogLevel.Fatal => Microsoft.Extensions.Logging.LogLevel.Error,
_ => Microsoft.Extensions.Logging.LogLevel.Error
}, args.ToString());
bot.Invoker.OnBotCaptchaEvent += (_, @event) =>
{
Console.WriteLine(@event.ToString());
var captcha = Console.ReadLine();
var randStr = Console.ReadLine();
if (captcha != null && randStr != null) bot.SubmitCaptcha(captcha, randStr);
};
bot.Invoker.OnGroupMessageReceived += InvokerOnOnGroupMessageReceived;

if (botKeystore is null)
{
bot = BotFactory.Create(new BotConfig(), await GetDeviceInfo(), new BotKeystore());

var result = await bot.FetchQrCode();
if (!result.HasValue) throw new InvalidOperationException("Lagrange无法获得二维码");
Expand All @@ -102,18 +124,9 @@ public async ValueTask Run()
}
else
{
bot = BotFactory.Create(new BotConfig(), await GetDeviceInfo(), botKeystore);
await bot.LoginByPassword();
}
bot.Invoker.OnBotLogEvent += (_, args) => botLogger.Log(args.Level switch
{
LogLevel.Debug => Microsoft.Extensions.Logging.LogLevel.Trace,
LogLevel.Verbose => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Information => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Warning => Microsoft.Extensions.Logging.LogLevel.Warning,
LogLevel.Fatal => Microsoft.Extensions.Logging.LogLevel.Error,
_ => Microsoft.Extensions.Logging.LogLevel.Error
}, args.ToString());
bot.Invoker.OnGroupMessageReceived += InvokerOnOnGroupMessageReceived;
await bot.LoginByPassword();

logger.LogInformation("等待登录中...");
await WaitBotOnlineAsync();
Expand Down
6 changes: 6 additions & 0 deletions Mikibot.Analyze/MiraiHttp/LagrangeSignService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Mikibot.Analyze.MiraiHttp;

public class LagrangeSignService
{

}
23 changes: 12 additions & 11 deletions Mikibot.Analyze/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#if DEBUG
appBuilder.RegisterType<ConsoleMiraiService>().As<IMiraiService>().SingleInstance();
appBuilder.RegisterType<LocalOssService>().As<IOssService>().SingleInstance();
appBuilder.RegisterType<ConsoleEmailService>().As<IEmailService>().SingleInstance();
// appBuilder.RegisterType<ConsoleEmailService>().As<IEmailService>().SingleInstance();
appBuilder.RegisterType<LagrangeBotBridge>().As<IMiraiService>().SingleInstance();
#else
appBuilder.RegisterType<LagrangeBotBridge>().As<IMiraiService>().SingleInstance();
// appBuilder.RegisterType<MiraiService>().As<IMiraiService>().SingleInstance();
Expand Down Expand Up @@ -73,11 +74,11 @@

var statusCrawler = app.Resolve<LiveStatusCrawlService>();
var followerStat = app.Resolve<DailyFollowerStatisticService>();
var eventService = app.Resolve<LiveStreamEventService>();
// var eventService = app.Resolve<LiveStreamEventService>();

var danmakuClip = app.Resolve<DanmakuRecordControlService>();
var danmakuCrawler = app.Resolve<DanmakuCollectorService>();
var danmakuExportGuard = app.Resolve<DanmakuExportGuardList>();
// var danmakuClip = app.Resolve<DanmakuRecordControlService>();
// var danmakuCrawler = app.Resolve<DanmakuCollectorService>();
// var danmakuExportGuard = app.Resolve<DanmakuExportGuardList>();

var aiVoice = app.Resolve<AiVoiceGenerationService>();
//var aiImage = app.Resolve<AiImageGenerationService>();
Expand All @@ -89,19 +90,19 @@
var optionaSelector = app.Resolve<OptionaSelectorService>();
var pingti = app.Resolve<PingtiItemReplaceService>();

eventService.CmdHandler.Register(danmakuCrawler);
eventService.CmdHandler.Register(mxmkLiveEventProxy);
// eventService.CmdHandler.Register(danmakuCrawler);
// eventService.CmdHandler.Register(mxmkLiveEventProxy);

eventService.CmdHandler.Subscribe<DanmuMsg>(danmakuClip.HandleDanmu);
eventService.CmdHandler.Subscribe<DanmuMsg>(danmakuExportGuard.HandleDanmaku);
eventService.CmdHandler.Subscribe<DanmuMsg>(mxmkDanmakuProxy.HandleDanmaku);
// eventService.CmdHandler.Subscribe<DanmuMsg>(danmakuClip.HandleDanmu);
// eventService.CmdHandler.Subscribe<DanmuMsg>(danmakuExportGuard.HandleDanmaku);
// eventService.CmdHandler.Subscribe<DanmuMsg>(mxmkDanmakuProxy.HandleDanmaku);

logger.LogInformation("Starting schedule module...");
await Task.WhenAll(
[
statusCrawler.Run(token),
followerStat.Run(token),
eventService.Run(token),
// eventService.Run(token),
bffAnti.Run(token),
biliParser.Run(token),
randomImage.Run(token),
Expand Down

0 comments on commit 934fcbc

Please sign in to comment.