From 1a435f2938c470ddeb209bf59a9852952277f709 Mon Sep 17 00:00:00 2001 From: Chr_ Date: Wed, 2 Mar 2022 18:57:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASFEnhance/ASFEnhance.cs | 10 +- ASFEnhance/ASFEnhance.csproj | 1 - ASFEnhance/AssemblyInfo.cs | 6 +- ASFEnhance/Event/Command.cs | 203 +----------------------------- ASFEnhance/Utils.cs | 2 +- ASFEnhance/WishList/WebRequest.cs | 3 - README.md | 2 +- README.zh-CN.md | 2 +- 8 files changed, 13 insertions(+), 216 deletions(-) diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index 3979954a..e1d012a9 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -6,6 +6,7 @@ using Chrxw.ASFEnhance.Localization; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -23,7 +24,8 @@ internal sealed class ASFEnhance : IASF, IBotCommand2 public string Name => nameof(ASFEnhance); public Version Version => typeof(ASFEnhance).Assembly.GetName().Version ?? throw new ArgumentNullException(nameof(Version)); - private bool DeveloperFeature = false; + [JsonProperty] + public bool DeveloperFeature { get; private set; } = false; /// /// ASF启动事件 @@ -42,7 +44,7 @@ public Task OnASFInit(IReadOnlyDictionary? additionalConfigPrope switch (configProperty) { case "ASFEnhanceDevFuture" when configValue.Type == JTokenType.Boolean: - this.DeveloperFeature = configValue.Value(); + DeveloperFeature = configValue.Value(); break; } } @@ -57,10 +59,10 @@ public Task OnASFInit(IReadOnlyDictionary? additionalConfigPrope public Task OnLoaded() { Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; - ASFLogger.LogGenericInfo(string.Format(CurrentCulture, Langs.PluginVer, version.Major, version.Minor, version.Build, version.Revision)); + ASFLogger.LogGenericInfo(string.Format(CurrentCulture, Langs.PluginVer, nameof(ASFEnhance), version.Major, version.Minor, version.Build, version.Revision)); ASFLogger.LogGenericInfo(string.Format(CurrentCulture, Langs.PluginContact)); - if (this.DeveloperFeature) + if (DeveloperFeature) { ASFLogger.LogGenericWarning(string.Format(CurrentCulture, Langs.DevFeatureEnabledWarning)); } diff --git a/ASFEnhance/ASFEnhance.csproj b/ASFEnhance/ASFEnhance.csproj index 86f760e1..8538261d 100644 --- a/ASFEnhance/ASFEnhance.csproj +++ b/ASFEnhance/ASFEnhance.csproj @@ -52,7 +52,6 @@ - diff --git a/ASFEnhance/AssemblyInfo.cs b/ASFEnhance/AssemblyInfo.cs index 810cc584..cba244b1 100644 --- a/ASFEnhance/AssemblyInfo.cs +++ b/ASFEnhance/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: System.CLSCompliant(false)] -[assembly: AssemblyVersion("1.5.14.233")] -[assembly: AssemblyFileVersion("1.5.14.233")] +[assembly: AssemblyVersion("1.5.14.235")] +[assembly: AssemblyFileVersion("1.5.14.235")] -[assembly: AssemblyCopyright("Copyright © 2021 Chr_")] +[assembly: AssemblyCopyright("Copyright © 2022 Chr_")] [assembly: AssemblyProduct("ASFEnhance")] [assembly: AssemblyCompany("chrxw.com")] [assembly: AssemblyTitle("An ArchiSteamFarm plugin developed by Chr_.")] diff --git a/ASFEnhance/Event/Command.cs b/ASFEnhance/Event/Command.cs index 56941aa7..4d79a832 100644 --- a/ASFEnhance/Event/Command.cs +++ b/ASFEnhance/Event/Command.cs @@ -8,7 +8,6 @@ using SteamKit2; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using static Chrxw.ASFEnhance.Event.Response; @@ -18,206 +17,6 @@ namespace Chrxw.ASFEnhance.Event { internal static class Command { - // 冬促投票 - internal static async Task ResponseSteamAwardVote(Bot bot, ulong steamID, string gameIDs) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - // if (!bot.HasAccess(steamID, BotConfig.EAccess.Operator)) - // { - // return null; - // } - - if (!bot.IsConnectedAndLoggedOn) - { - return FormatBotResponse(bot, Strings.BotNotConnected); - } - - string[] entries = gameIDs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - - List intGamsIDs = new(); - - foreach (string entry in entries) - { - if (uint.TryParse(entry, out uint choice)) - { - intGamsIDs.Add(choice); - if (intGamsIDs.Count >= 10) - { - break; - } - } - } - - if (intGamsIDs.Count < 10) //不足10个游戏自动补齐 - { - Random rd = new(); - uint[,] aviliableChoose = new uint[,] { - { 892970 ,1063730 ,1091500 ,1196590 ,1551360 } , - { 752480 ,1358140 ,1402320 ,1499120 ,1576350 }, - { 570 ,105600 ,252490 ,275850 ,1172470 }, - { 892970 ,924970 ,1240440 ,1426210 ,1782210 }, - { 607080 ,848450 ,860510 ,1178830 ,1551360 }, - { 1092790 ,1097200 ,1195290 ,1252330 ,1282730 }, - { 699130 ,1203220 ,1325200 ,1466860 ,1517290 }, - { 1088850 ,1113560 ,1382330 ,1384160 ,1490890 }, - { 936790 ,1091500 ,1196590 ,1259420 ,1328670 }, - { 1135690 ,1210320 ,1248130 ,1291340 ,1455840 } - }; - for (int i = intGamsIDs.Count; i < 10; i++) - { - intGamsIDs.Add(aviliableChoose[i, rd.Next(0, 5)]); - } - } - - for (int i = 0; i < 10; i++) - { - int categoryID = 61 + i; - await WebRequest.MakeVote(bot, intGamsIDs[i], categoryID).ConfigureAwait(false); - } - - uint? voteCount = await WebRequest.CheckSummerBadge(bot).ConfigureAwait(false); - - if (voteCount == null) - { - return FormatBotResponse(bot, Langs.EventReadBadgeStatusFailed); - } - - return FormatBotResponse(bot, string.Format(CurrentCulture, Langs.EventVoteResponse, voteCount, 10)); - } - - // 冬促投票(多个Bot) - internal static async Task ResponseSteamAwardVote(ulong steamID, string botNames, string choose) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - if (string.IsNullOrEmpty(botNames)) - { - throw new ArgumentNullException(nameof(botNames)); - } - - HashSet? bots = Bot.GetBots(botNames); - - if ((bots == null) || (bots.Count == 0)) - { - // return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CurrentCulture, Strings.BotNotFound, botNames)) : null; - } - - IList results = await Utilities.InParallel(bots.Select(bot => ResponseSteamAwardVote(bot, steamID, choose))).ConfigureAwait(false); - - List responses = new(results.Where(result => !string.IsNullOrEmpty(result))!); - - return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; - } - - // 检查冬促徽章 - internal static async Task ResponseCheckSteamAwardVote(Bot bot, ulong steamID) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - // if (!bot.HasAccess(steamID, BotConfig.EAccess.Operator)) - // { - // return null; - // } - - if (!bot.IsConnectedAndLoggedOn) - { - return FormatBotResponse(bot, Strings.BotNotConnected); - } - - uint? voteCount = await WebRequest.CheckSummerBadge(bot).ConfigureAwait(false); - - if (voteCount == null) - { - return FormatBotResponse(bot, Langs.EventReadBadgeStatusFailed); - } - - return FormatBotResponse(bot, string.Format(CurrentCulture, Langs.EventVoteResponse, voteCount, 10)); - } - - // 冬促投票(多个Bot) - internal static async Task ResponseCheckSteamAwardVote(ulong steamID, string botNames) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - if (string.IsNullOrEmpty(botNames)) - { - throw new ArgumentNullException(nameof(botNames)); - } - - HashSet? bots = Bot.GetBots(botNames); - - if ((bots == null) || (bots.Count == 0)) - { - // return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CurrentCulture, Strings.BotNotFound, botNames)) : null; - } - - IList results = await Utilities.InParallel(bots.Select(bot => ResponseCheckSteamAwardVote(bot, steamID))).ConfigureAwait(false); - - List responses = new(results.Where(result => !string.IsNullOrEmpty(result))!); - - return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; - } - // 领取每日贴纸 - internal static async Task ResponseClaimDailySticker(Bot bot, ulong steamID) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - // if (!bot.HasAccess(steamID, BotConfig.EAccess.Operator)) - // { - // return null; - // } - - if (!bot.IsConnectedAndLoggedOn) - { - return FormatBotResponse(bot, Strings.BotNotConnected); - } - - bool? result = await WebRequest.ClaimDailySticker(bot).ConfigureAwait(false); - - return FormatBotResponse(bot, string.Format(CurrentCulture, Langs.EventClaimItem, result)); - } - - // 领取每日贴纸(多个Bot) - internal static async Task ResponseClaimDailySticker(ulong steamID, string botNames) - { - if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) - { - throw new InvalidEnumArgumentException(nameof(steamID)); - } - - if (string.IsNullOrEmpty(botNames)) - { - throw new ArgumentNullException(nameof(botNames)); - } - - HashSet? bots = Bot.GetBots(botNames); - - if ((bots == null) || (bots.Count == 0)) - { - // return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CurrentCulture, Strings.BotNotFound, botNames)) : null; - } - - IList results = await Utilities.InParallel(bots.Select(bot => ResponseClaimDailySticker(bot, steamID))).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/Utils.cs b/ASFEnhance/Utils.cs index 949d69b3..db18dc86 100644 --- a/ASFEnhance/Utils.cs +++ b/ASFEnhance/Utils.cs @@ -9,7 +9,7 @@ namespace Chrxw.ASFEnhance { - internal class Utils + internal static class Utils { /// /// 格式化返回文本 diff --git a/ASFEnhance/WishList/WebRequest.cs b/ASFEnhance/WishList/WebRequest.cs index c6589860..a4095681 100644 --- a/ASFEnhance/WishList/WebRequest.cs +++ b/ASFEnhance/WishList/WebRequest.cs @@ -1,6 +1,5 @@ #pragma warning disable CS8632 // 只能在 "#nullable" 注释上下文内的代码中使用可为 null 的引用类型的注释。 -using ArchiSteamFarm.Core; using ArchiSteamFarm.Localization; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Steam.Data; @@ -24,7 +23,6 @@ internal static class WebRequest /// /// /// - /// internal static async Task AddWishlist(Bot bot, uint gameID) { if (gameID == 0) @@ -62,7 +60,6 @@ internal static async Task AddWishlist(Bot bot, uint gameID) /// /// /// - /// internal static async Task RemoveWishlist(Bot bot, uint gameID) { if (gameID == 0) diff --git a/README.md b/README.md index 11e8b10d..e1e5cb33 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Post link: [https://keylol.com/t716051-1-1](https://keylol.com/t716051-1-1) | ASFEnhance Version | Compile Use ASF Version | Supported Lowest ASF Version | Note | | -------------------------------------------------------------------------- | ----------------------- | ---------------------------- | ---------------------------------------------- | -| [1.5.14.233](https://github.com/chr233/ASFEnhance/releases/tag/1.5.14.233) | 5.2.2.5 | 5.2.2.5 | Plugin API changed, nolonger supported old ASF | +| [1.5.14.235](https://github.com/chr233/ASFEnhance/releases/tag/1.5.14.235) | 5.2.2.5 | 5.2.2.5 | Plugin API changed, nolonger supported old ASF | | [1.5.13.231](https://github.com/chr233/ASFEnhance/releases/tag/1.5.13.231) | 5.1.2.5 | 5.1.2.5 | - | | [1.5.12.230](https://github.com/chr233/ASFEnhance/releases/tag/1.5.12.230) | 5.1.2.5 | 5.1.2.5 | Migrate to .net6.0, nolonger supported old ASF | diff --git a/README.zh-CN.md b/README.zh-CN.md index f5b6afd5..cd0e846f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -21,7 +21,7 @@ | ASFEnhance 版本 | 编译依赖的 ASF 版本 | 最低支持的 ASF 版本 | 备注 | | -------------------------------------------------------------------------- | ------------------- | ------------------- | -------------------------------- | -| [1.5.14.233](https://github.com/chr233/ASFEnhance/releases/tag/1.5.14.233) | 5.2.2.5 | 5.2.2.5 | 插件 API 更改, 无法兼容旧版 ASF | +| [1.5.14.235](https://github.com/chr233/ASFEnhance/releases/tag/1.5.14.235) | 5.2.2.5 | 5.2.2.5 | 插件 API 更改, 无法兼容旧版 ASF | | [1.5.13.231](https://github.com/chr233/ASFEnhance/releases/tag/1.5.13.231) | 5.1.2.5 | 5.1.2.5 | - | | [1.5.12.230](https://github.com/chr233/ASFEnhance/releases/tag/1.5.12.230) | 5.1.2.5 | 5.1.2.5 | 切换到 .net6.0, 无法兼容旧版 ASF |