diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs index dc490685..d57f3d2a 100644 --- a/ASFEnhance/ASFEnhance.cs +++ b/ASFEnhance/ASFEnhance.cs @@ -2,16 +2,13 @@ using ArchiSteamFarm.Plugins.Interfaces; using ArchiSteamFarm.Steam; using ArchiSteamFarm.Web.GitHub; -using ArchiSteamFarm.Web.GitHub.Data; using ASFEnhance.Data.Plugin; using System.ComponentModel; using System.Composition; -using System.Globalization; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using static ArchiSteamFarm.Storage.GlobalConfig; -using static SteamKit2.GC.Dota.Internal.CMsgDOTALeague; namespace ASFEnhance; @@ -362,6 +359,9 @@ public Task OnLoaded() "CML" when access >= EAccess.Operator => Account.Command.ResponseCheckMarketLimit(bot), + "PHONESUFFIX" when access >= EAccess.Operator => + Account.Command.ResponseGetPhoneSuffix(bot), + //Cart "CART" or "C" when access >= EAccess.Operator => @@ -652,6 +652,9 @@ public Task OnLoaded() "CML" when access >= EAccess.Operator => Account.Command.ResponseCheckMarketLimit(Utilities.GetArgsAsText(args, 1, ",")), + "PHONESUFFIX" when access >= EAccess.Operator => + Account.Command.ResponseGetPhoneSuffix(Utilities.GetArgsAsText(args, 1, ",")), + //Cart "CART" or "C" when access >= EAccess.Operator => diff --git a/ASFEnhance/Account/Command.cs b/ASFEnhance/Account/Command.cs index 4ac8c5d4..6a4d5118 100644 --- a/ASFEnhance/Account/Command.cs +++ b/ASFEnhance/Account/Command.cs @@ -1347,4 +1347,50 @@ private static string NotificationTargetToString(NotificationTarget target) return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } + + /// + /// 检查市场限制 + /// + /// + /// + /// + /// + internal static async Task ResponseGetPhoneSuffix(Bot bot) + { + if (!bot.IsConnectedAndLoggedOn) + { + return bot.FormatBotResponse(Strings.BotNotConnected); + } + + var response = await WebRequest.GetPhoneSuffix(bot).ConfigureAwait(false); + return bot.FormatBotResponse(response ?? Langs.GetPhoneSuffixFailed); + } + + /// + /// 检查市场限制 (多个Bot) + /// + /// + /// + /// + /// + /// + internal static async Task ResponseGetPhoneSuffix(string botNames) + { + if (string.IsNullOrEmpty(botNames)) + { + throw new ArgumentNullException(nameof(botNames)); + } + + var bots = Bot.GetBots(botNames); + + if (bots == null || bots.Count == 0) + { + return FormatStaticResponse(Strings.BotNotFound, botNames); + } + + var results = await Utilities.InParallel(bots.Select(bot => ResponseGetPhoneSuffix(bot))).ConfigureAwait(false); + var responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); + + return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; + } } diff --git a/ASFEnhance/Account/WebRequest.cs b/ASFEnhance/Account/WebRequest.cs index f1be7b62..e0f39e1e 100644 --- a/ASFEnhance/Account/WebRequest.cs +++ b/ASFEnhance/Account/WebRequest.cs @@ -481,6 +481,11 @@ internal static async Task ToggleAppPrivacy(Bot bot, List appIds, bo return response; } + /// + /// 获取市场是否受限 + /// + /// + /// internal static async Task GetIfMarketLimited(Bot bot) { var request = new Uri(SteamCommunityURL, "/market/"); @@ -501,4 +506,22 @@ internal static async Task ToggleAppPrivacy(Bot bot, List appIds, bo return false; } } + + /// + /// 获取电话号码后缀 + /// + /// + /// + internal static async Task GetPhoneSuffix(Bot bot) + { + var request = new Uri(SteamStoreURL, $"/phone/manage?l={Langs.Language}"); + var response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(request).ConfigureAwait(false); + + if (response?.Content == null) + { + return null; + } + + return response.Content.QuerySelector("div.phone_header_description>span")?.TextContent?.Trim(); + } } diff --git a/Directory.Build.props b/Directory.Build.props index 9c28cf4f..72f61f6a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 2.1.8.2 + 2.1.8.3