diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index 2de9aa4..47752e0 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -249,9 +249,13 @@ public Task OnLoaded() "C20" when access >= EAccess.Operator => Event.Command.ResponseClaim20Th(bot), - //"CV" or - //"CHECKVOTE" when access >= EAccess.Operator => - // Event.Command.ResponseCheckWinterSteamAwardVote(bot), + "V" or + "VOTE" when access >= EAccess.Operator => + Event.Command.ResponseAutumnSteamAwardVote(bot, ""), + + "CV" or + "CHECKVOTE" when access >= EAccess.Operator => + Event.Command.ResponseCheckAutumnSteamAwardVote(bot), //Shortcut "P" => @@ -504,9 +508,16 @@ public Task OnLoaded() "C20" when access >= EAccess.Operator => Event.Command.ResponseClaim20Th(Utilities.GetArgsAsText(args, 1, ",")), - //"CV" or - //"CHECKVOTE" when access >= EAccess.Operator => - // Event.Command.ResponseCheckWinterSteamAwardVote(Utilities.GetArgsAsText(args, 1, ",")), + "V" or + "VOTE" when argLength > 2 && access >= EAccess.Operator => + Event.Command.ResponseAutumnSteamAwardVote(args[1], Utilities.GetArgsAsText(args, 2, ",")), + "V" or + "VOTE" when access >= EAccess.Operator => + Event.Command.ResponseAutumnSteamAwardVote(args[1], ""), + + "CV" or + "CHECKVOTE" when access >= EAccess.Operator => + Event.Command.ResponseCheckAutumnSteamAwardVote(Utilities.GetArgsAsText(args, 1, ",")), //Shortcut "AL" => diff --git a/ASFEnhance/Event/Command.cs b/ASFEnhance/Event/Command.cs index 5a7c007..5e29f9e 100644 --- a/ASFEnhance/Event/Command.cs +++ b/ASFEnhance/Event/Command.cs @@ -6,8 +6,10 @@ namespace ASFEnhance.Event; internal static class Command { + private const int categoryBegin = 110; + /// - /// 获取DL2贴纸 6.28 - ? + /// 获取DL2贴纸 6.28 - ? /// /// /// @@ -47,7 +49,7 @@ internal static class Command } /// - /// 获取DL2贴纸 (多个Bot) + /// 获取DL2贴纸 (多个Bot) /// /// /// @@ -62,7 +64,7 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } @@ -74,7 +76,7 @@ internal static class Command } /// - /// 领取活动道具 + /// 领取活动道具 /// /// /// @@ -97,17 +99,16 @@ internal static class Command { return bot.FormatBotResponse(Langs.NoItemToClaim); } - else - { - var name = result.Response.RewardItem.CommunityItemData?.ItemName ?? result.Response.RewardItem.CommunityItemData?.ItemTitle ?? "UNKNOWN"; - var localTime = DateTimeOffset.FromUnixTimeSeconds(result.Response.NextClaimTime).LocalDateTime; - return bot.FormatBotResponse(Langs.ClaimItemSuccessful, name, localTime.ToString("yyyy-MM-dd HH:mm:ss")); - } + var name = result.Response.RewardItem.CommunityItemData?.ItemName ?? + result.Response.RewardItem.CommunityItemData?.ItemTitle ?? "UNKNOWN"; + var localTime = DateTimeOffset.FromUnixTimeSeconds(result.Response.NextClaimTime).LocalDateTime; + + return bot.FormatBotResponse(Langs.ClaimItemSuccessful, name, localTime.ToString("yyyy-MM-dd HH:mm:ss")); } /// - /// 领取活动道具 (多个Bot) + /// 领取活动道具 (多个Bot) /// /// /// @@ -121,7 +122,7 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } @@ -133,7 +134,7 @@ internal static class Command } /// - /// 领取20周年贴纸 + /// 领取20周年贴纸 /// /// /// @@ -150,8 +151,17 @@ internal static class Command return bot.FormatBotResponse(Langs.NetworkError); } - var defIds = new List { 241812, 241811, 241810, 241809, 241807, 241808 }; - var results = await Utilities.InParallel(defIds.Select(id => WebRequest.RedeenPointShopItem(bot, token, id))).ConfigureAwait(false); + var defIds = new List + { + 241812, + 241811, + 241810, + 241809, + 241807, + 241808 + }; + var results = await Utilities.InParallel(defIds.Select(id => WebRequest.RedeenPointShopItem(bot, token, id))) + .ConfigureAwait(false); var count = 0; foreach (var result in results) @@ -166,7 +176,7 @@ internal static class Command } /// - /// 领取20周年贴纸 (多个Bot) + /// 领取20周年贴纸 (多个Bot) /// /// /// @@ -180,7 +190,7 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } @@ -192,7 +202,7 @@ internal static class Command } /// - /// 秋促投票 + /// 秋促投票 /// /// /// @@ -206,25 +216,28 @@ internal static class Command var entries = gameIDs.Split(SeparatorDot, StringSplitOptions.RemoveEmptyEntries); - var intGamsIDs = new List(); + List intGamsIDs = []; const int categories = 11; - foreach (string entry in entries) + foreach (var entry in entries) { - if (int.TryParse(entry, out var choice) && choice > 0) + if (!int.TryParse(entry, out var choice) || choice <= 0) { - intGamsIDs.Add(choice); - if (intGamsIDs.Count >= categories) - { - break; - } + continue; + } + + intGamsIDs.Add(choice); + if (intGamsIDs.Count >= categories) + { + break; } } if (intGamsIDs.Count < categories) //不足11个游戏自动补齐 { - List defaultGames = [1086940, 1922010, 1374480, 990080, 2344520, 2254740, 2411910, 1817230, 2242710, 1868140, 2194530]; + List defaultGames = + [2358720, 2669410, 548430, 2230650, 1623730, 2358720, 2679460, 2358720, 2358720, 2704110, 3097560]; while (intGamsIDs.Count < categories) { intGamsIDs.Add(defaultGames[intGamsIDs.Count]); @@ -240,11 +253,11 @@ internal static class Command var semaphore = new SemaphoreSlim(1); - var tasks = new List(); + List tasks = []; - for (int i = 0; i < categories; i++) + for (var i = 0; i < categories; i++) { - tasks.Add(WebRequest.MakeVoteForAutumnSale(bot, intGamsIDs[i], 90 + i, token, semaphore)); + tasks.Add(WebRequest.MakeVoteForAutumnSale(bot, intGamsIDs[i], categoryBegin + i, token, semaphore)); } await Utilities.InParallel(tasks).ConfigureAwait(false); @@ -254,7 +267,7 @@ internal static class Command } /// - /// 秋促投票 (多个Bot) + /// 秋促投票 (多个Bot) /// /// /// @@ -269,19 +282,20 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } - var results = await Utilities.InParallel(bots.Select(bot => ResponseAutumnSteamAwardVote(bot, choose))).ConfigureAwait(false); + var results = await Utilities.InParallel(bots.Select(bot => ResponseAutumnSteamAwardVote(bot, choose))) + .ConfigureAwait(false); var responses = new List(results.Where(result => !string.IsNullOrEmpty(result))!); return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } /// - /// 检查秋促徽章 + /// 检查秋促徽章 /// /// /// @@ -299,7 +313,7 @@ internal static class Command } /// - /// 检查秋促徽章 (多个Bot) + /// 检查秋促徽章 (多个Bot) /// /// /// @@ -313,19 +327,20 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } - var results = await Utilities.InParallel(bots.Select(bot => ResponseCheckAutumnSteamAwardVote(bot))).ConfigureAwait(false); + var results = await Utilities.InParallel(bots.Select(ResponseCheckAutumnSteamAwardVote)) + .ConfigureAwait(false); var responses = new List(results.Where(result => !string.IsNullOrEmpty(result))!); return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } /// - /// 冬促投票 + /// 冬促投票 /// /// /// @@ -339,25 +354,28 @@ internal static class Command var entries = gameIDs.Split(SeparatorDot, StringSplitOptions.RemoveEmptyEntries); - var intGamsIDs = new List(); + List intGamsIDs = []; const int categories = 11; - foreach (string entry in entries) + foreach (var entry in entries) { - if (int.TryParse(entry, out var choice) && choice > 0) + if (!int.TryParse(entry, out var choice) || choice <= 0) + { + continue; + } + + intGamsIDs.Add(choice); + if (intGamsIDs.Count >= categories) { - intGamsIDs.Add(choice); - if (intGamsIDs.Count >= categories) - { - break; - } + break; } } if (intGamsIDs.Count < categories) //不足11个游戏自动补齐 { - List defaultGames = [1086940, 1957780, 548430, 990080, 1260320, 668580, 1716740, 2138710, 1817230, 2322560, 1868140]; + List defaultGames = + [2358720, 2669410, 548430, 2230650, 1623730, 2358720, 2679460, 2358720, 2358720, 2704110, 3097560]; while (intGamsIDs.Count < categories) { intGamsIDs.Add(defaultGames[intGamsIDs.Count]); @@ -373,11 +391,11 @@ internal static class Command var semaphore = new SemaphoreSlim(1); - var tasks = new List(); + List tasks = []; - for (int i = 0; i < categories; i++) + for (var i = 0; i < categories; i++) { - tasks.Add(WebRequest.MakeWinterSteamAwardVote(bot, intGamsIDs[i], 90 + i, token, semaphore)); + tasks.Add(WebRequest.MakeWinterSteamAwardVote(bot, intGamsIDs[i], categoryBegin + i, token, semaphore)); } await Utilities.InParallel(tasks).ConfigureAwait(false); @@ -387,7 +405,7 @@ internal static class Command } /// - /// 冬促投票 (多个Bot) + /// 冬促投票 (多个Bot) /// /// /// @@ -402,19 +420,20 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } - var results = await Utilities.InParallel(bots.Select(bot => ResponseWinterSteamAwardVote(bot, choose))).ConfigureAwait(false); + var results = await Utilities.InParallel(bots.Select(bot => ResponseWinterSteamAwardVote(bot, choose))) + .ConfigureAwait(false); var responses = new List(results.Where(result => !string.IsNullOrEmpty(result))!); return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } /// - /// 检查冬促投票 + /// 检查冬促投票 /// /// /// @@ -438,7 +457,7 @@ internal static class Command } /// - /// 检查冬促投票 (多个Bot) + /// 检查冬促投票 (多个Bot) /// /// /// @@ -452,14 +471,15 @@ internal static class Command var bots = Bot.GetBots(botNames); - if ((bots == null) || (bots.Count == 0)) + if (bots == null || bots.Count == 0) { return FormatStaticResponse(Strings.BotNotFound, botNames); } - var results = await Utilities.InParallel(bots.Select(bot => ResponseCheckWinterSteamAwardVote(bot))).ConfigureAwait(false); + var results = await Utilities.InParallel(bots.Select(bot => ResponseCheckWinterSteamAwardVote(bot))) + .ConfigureAwait(false); var responses = new List(results.Where(result => !string.IsNullOrEmpty(result))!); return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } -} +} \ No newline at end of file diff --git a/ASFEnhance/Event/WebRequest.cs b/ASFEnhance/Event/WebRequest.cs index e54c3ef..03bada0 100644 --- a/ASFEnhance/Event/WebRequest.cs +++ b/ASFEnhance/Event/WebRequest.cs @@ -153,7 +153,7 @@ internal static async Task MakeVoteForAutumnSale(Bot bot, int gameID, int catego { CategoryId = categoryID, NominatedId = gameID, - Source = 7, + Source = 6, }; var enc = ProtoBufEncode(payload).Replace("=", "%3D").Replace("+", "%2B"); @@ -175,7 +175,7 @@ internal static async Task MakeVoteForAutumnSale(Bot bot, int gameID, int catego /// internal static async Task CheckAutumnSaleBadge(Bot bot) { - var request = new Uri(SteamCommunityURL, "/profiles/" + bot.SteamID.ToString() + "/badges/65"); + var request = new Uri(SteamCommunityURL, "/profiles/" + bot.SteamID.ToString() + "/badges/67"); var response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(request, referer: SteamCommunityURL).ConfigureAwait(false); diff --git a/Directory.Build.props b/Directory.Build.props index a4adc15..4f40845 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 2.2.7.0 + 2.2.8.0