Skip to content

Commit

Permalink
修改 EVENT 命令 新增 EVENTENDLESS 命令
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Jun 14, 2022
1 parent e2c2f84 commit 8e7f021
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
10 changes: 8 additions & 2 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
22 changes: 17 additions & 5 deletions ASFEnhance/Event/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ASFEnhance.Event
{
internal static class Command
{
internal static async Task<string?> ResponseEvent(Bot bot)
internal static async Task<string?> ResponseEvent(Bot bot, bool endless)
{
if (!bot.IsConnectedAndLoggedOn)
{
Expand Down Expand Up @@ -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)
Expand All @@ -70,7 +82,7 @@ internal static class Command
return bot.FormatBotResponse("任务将在后台运行");
}

internal static async Task<string?> ResponseEvent(string botNames)
internal static async Task<string?> ResponseEvent(string botNames, bool endless)
{
if (string.IsNullOrEmpty(botNames))
{
Expand All @@ -84,7 +96,7 @@ internal static class Command
return FormatStaticResponse(string.Format(Strings.BotNotFound, botNames));
}

IList<string?> results = await Utilities.InParallel(bots.Select(bot => ResponseEvent(bot))).ConfigureAwait(false);
IList<string?> results = await Utilities.InParallel(bots.Select(bot => ResponseEvent(bot, endless))).ConfigureAwait(false);

List<string> responses = new(results.Where(result => !string.IsNullOrEmpty(result))!);

Expand Down

0 comments on commit 8e7f021

Please sign in to comment.