//读取购物车(多个Bot) private static async Task <string?> ResponseGetCartGames(ulong steamID, string botNames) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { throw new ArgumentOutOfRangeException(nameof(steamID)); } if (string.IsNullOrEmpty(botNames)) { throw new ArgumentNullException(nameof(botNames)); } HashSet <Bot>?bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { return(ASF.IsOwner(steamID) ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null); } IList <string?> results = await Utilities.InParallel(bots.Select(bot => ResponseGetCartGames(bot, steamID))).ConfigureAwait(false); List <string> responses = new(results.Where(result => !string.IsNullOrEmpty(result)) !); return(responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null); }
private static async Task <string> ResponseBooster(ulong steamID, string botNames, string targetGameIDs) { if ((steamID == 0) || string.IsNullOrEmpty(botNames) || string.IsNullOrEmpty(targetGameIDs)) { ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(targetGameIDs)); return(null); } HashSet <Bot> bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { return(ASF.IsOwner(steamID) ? FormatStaticResponse(string.Format(Strings.BotNotFound, botNames)) : null); } IList <string> results = await Utilities.InParallel(bots.Select(bot => ResponseBooster(bot, steamID, targetGameIDs))).ConfigureAwait(false); List <string> responses = new List <string>(results.Where(result => !string.IsNullOrEmpty(result))); return(responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null); }
public async Task <string?> ResponseRandomAvatar(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return(null); } HashSet <Bot>?bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { return(ASF.IsOwner(steamID) ? Commands.FormatStaticResponse(string.Format(ArchiSteamFarm.Localization.Strings.BotNotFound, botNames)) : null); } IList <string?> results = await Utilities.InParallel(bots.Select(curbot => ResponseRandomAvatar(curbot, steamID))).ConfigureAwait(false); List <string?> responses = new List <string?>(results.Where(result => !string.IsNullOrEmpty(result))); return(responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null); }