diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index 73c41d51..e50bb727 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -175,6 +175,9 @@ private async Task ResponseCommand(Bot bot, EAccess access, string messa case "SIM4" when access >= EAccess.Operator: return await Event.Command.ResponseSim4(bot).ConfigureAwait(false); + + case "DL2" when access >= EAccess.Operator: + return await Event.Command.ResponseDL2(bot).ConfigureAwait(false); //Shortcut case "P": @@ -313,6 +316,9 @@ private async Task ResponseCommand(Bot bot, EAccess access, string messa case "SIM4" when access >= EAccess.Operator: return await Event.Command.ResponseSim4(Utilities.GetArgsAsText(args, 1, ",")).ConfigureAwait(false); + case "DL2" when access >= EAccess.Operator: + return await Event.Command.ResponseDL2(Utilities.GetArgsAsText(args, 1, ",")).ConfigureAwait(false); + //Shortcut case "AL": return await bot.Commands.Response(access, "ADDLICENSE " + Utilities.GetArgsAsText(message, 1), steamID).ConfigureAwait(false); diff --git a/ASFEnhance/AssemblyInfo.cs b/ASFEnhance/AssemblyInfo.cs index e3ece19d..65db6efc 100644 --- a/ASFEnhance/AssemblyInfo.cs +++ b/ASFEnhance/AssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Reflection; [assembly: CLSCompliant(false)] -[assembly: AssemblyVersion("1.6.17.2")] -[assembly: AssemblyFileVersion("1.6.17.2")] +[assembly: AssemblyVersion("1.6.18.0")] +[assembly: AssemblyFileVersion("1.6.18.0")] [assembly: AssemblyCopyright("Copyright © 2022 Chr_")] [assembly: AssemblyProduct("ASFEnhance")] diff --git a/ASFEnhance/Event/Command.cs b/ASFEnhance/Event/Command.cs index 4896e479..a269e7e9 100644 --- a/ASFEnhance/Event/Command.cs +++ b/ASFEnhance/Event/Command.cs @@ -21,7 +21,7 @@ internal static class Command return bot.FormatBotResponse(Strings.BotNotConnected); } - string token = await WebRequest.FetchEventToken(bot).ConfigureAwait(false); + string token = await WebRequest.FetchEventToken(bot, "simscelebrationsale").ConfigureAwait(false); if (token == null) { return bot.FormatBotResponse(Langs.NetworkError); @@ -38,10 +38,9 @@ internal static class Command } /// - /// 获取活动徽章 (多个Bot) + /// 获取SIM4贴纸 (多个Bot) /// /// - /// /// /// internal static async Task ResponseSim4(string botNames) @@ -64,5 +63,60 @@ internal static class Command return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } + + /// + /// 获取DL2贴纸 11.11 - ? + /// + /// + /// + internal static async Task ResponseDL2(Bot bot) + { + if (!bot.IsConnectedAndLoggedOn) + { + return bot.FormatBotResponse(Strings.BotNotConnected); + } + + string token = await WebRequest.FetchEventToken(bot, "dyinglight").ConfigureAwait(false); + if (token == null) + { + return bot.FormatBotResponse(Langs.NetworkError); + } + + uint[] door_indexs = { 1, 3, 4, 5, 2 }; + + foreach (uint index in door_indexs) + { + await WebRequest.DoEventTask(bot, token, index).ConfigureAwait(false); + } + + return bot.FormatBotResponse("Done!"); + } + + /// + /// 获取DL2贴纸 (多个Bot) + /// + /// + /// + /// + internal static async Task ResponseDL2(string botNames) + { + if (string.IsNullOrEmpty(botNames)) + { + throw new ArgumentNullException(nameof(botNames)); + } + + HashSet? bots = Bot.GetBots(botNames); + + if ((bots == null) || (bots.Count == 0)) + { + return FormatStaticResponse(string.Format(Strings.BotNotFound, botNames)); + } + + IList results = await Utilities.InParallel(bots.Select(bot => ResponseDL2(bot))).ConfigureAwait(false); + + List responses = new(results.Where(result => !string.IsNullOrEmpty(result))!); + + return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; + } } } diff --git a/ASFEnhance/Event/WebRequest.cs b/ASFEnhance/Event/WebRequest.cs index 8be7b9cd..3eea7ea6 100644 --- a/ASFEnhance/Event/WebRequest.cs +++ b/ASFEnhance/Event/WebRequest.cs @@ -14,7 +14,8 @@ internal static class WebRequest /// 模拟探索队列 /// /// - /// + /// + /// /// internal static async Task DoEventTask(Bot bot, string clan_accountid, uint door_index) { @@ -32,10 +33,11 @@ internal static async Task DoEventTask(Bot bot, string clan_accountid, uint door /// 获取Token /// /// + /// /// - internal static async Task FetchEventToken(Bot bot) + internal static async Task FetchEventToken(Bot bot,string salePage) { - Uri request = new(SteamStoreURL, "/sale/simscelebrationsale?tab=2"); + Uri request = new(SteamStoreURL, $"/sale/{salePage}"); var response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(request).ConfigureAwait(false);