From 8e7f0211894bcc076ffdaadc08ef55661b3fcd79 Mon Sep 17 00:00:00 2001 From: Chr_ Date: Tue, 14 Jun 2022 14:03:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20EVENT=20=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20EVENTENDLESS=20=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASFEnhance/ASFEnhance.cs | 10 ++++++++-- ASFEnhance/Event/Command.cs | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index 4d1fadb0..0e694b95 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -134,7 +134,10 @@ public Task OnLoaded() //Event case "EVENT" when access >= EAccess.Operator: case "E" when access >= EAccess.Operator: - return await Event.Command.ResponseEvent(bot).ConfigureAwait(false); + return await Event.Command.ResponseEvent(bot, false).ConfigureAwait(false); + case "EVENTENDLESS" when access >= EAccess.Operator: + case "EE" when access >= EAccess.Operator: + return await Event.Command.ResponseEvent(bot, true).ConfigureAwait(false); //Cart case "CART" when access >= EAccess.Operator: @@ -220,7 +223,10 @@ public Task OnLoaded() //Event case "EVENT" when access >= EAccess.Operator: case "E" when access >= EAccess.Operator: - return await Event.Command.ResponseEvent(Utilities.GetArgsAsText(message, 1)).ConfigureAwait(false); + return await Event.Command.ResponseEvent(Utilities.GetArgsAsText(message, 1), false).ConfigureAwait(false); + case "EVENTENDLESS" when access >= EAccess.Operator: + case "EE" when access >= EAccess.Operator: + return await Event.Command.ResponseEvent(Utilities.GetArgsAsText(message, 1), true).ConfigureAwait(false); //Community case "JOINGROUP" when args.Length > 2 && access >= EAccess.Master && access >= EAccess.Master: diff --git a/ASFEnhance/Event/Command.cs b/ASFEnhance/Event/Command.cs index ac88220e..6eebd96c 100644 --- a/ASFEnhance/Event/Command.cs +++ b/ASFEnhance/Event/Command.cs @@ -9,7 +9,7 @@ namespace ASFEnhance.Event { internal static class Command { - internal static async Task ResponseEvent(Bot bot) + internal static async Task ResponseEvent(Bot bot, bool endless) { if (!bot.IsConnectedAndLoggedOn) { @@ -49,10 +49,22 @@ internal static class Command ASFLogger.LogGenericInfo(r2); await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false); - if (i++ >= 35) + if (endless) { - break; + if (i++ >= 40) + { + i = 0; + await Task.Delay(TimeSpan.FromHours(1)).ConfigureAwait(false); + } } + else + { + if (i++ >= 10) + { + break; + } + } + } if (!bot.IsConnectedAndLoggedOn) @@ -70,7 +82,7 @@ internal static class Command return bot.FormatBotResponse("任务将在后台运行"); } - internal static async Task ResponseEvent(string botNames) + internal static async Task ResponseEvent(string botNames, bool endless) { if (string.IsNullOrEmpty(botNames)) { @@ -84,7 +96,7 @@ internal static class Command return FormatStaticResponse(string.Format(Strings.BotNotFound, botNames)); } - IList results = await Utilities.InParallel(bots.Select(bot => ResponseEvent(bot))).ConfigureAwait(false); + IList results = await Utilities.InParallel(bots.Select(bot => ResponseEvent(bot, endless))).ConfigureAwait(false); List responses = new(results.Where(result => !string.IsNullOrEmpty(result))!);