From a5c1b0c25368c94e6e7e37aa85f06ade6abf67f6 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 31 Jan 2017 22:03:20 +0100 Subject: [PATCH] Unify ASF newline responses --- ArchiSteamFarm/Bot.cs | 224 ++++++++++------------------ ArchiSteamFarm/ConcurrentHashSet.cs | 10 -- 2 files changed, 80 insertions(+), 154 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 41cc1ccf4..d3587c0b9 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -1618,11 +1618,11 @@ namespace ArchiSteamFarm { } if (!HasMobileAuthenticator) { - return Strings.BotNoASFAuthenticator; + return Environment.NewLine + Strings.BotNoASFAuthenticator; } string token = await BotDatabase.MobileAuthenticator.GenerateToken().ConfigureAwait(false); - return !string.IsNullOrEmpty(token) ? string.Format(Strings.BotAuthenticatorToken, token) : Strings.WarningFailed; + return Environment.NewLine + (!string.IsNullOrEmpty(token) ? string.Format(Strings.BotAuthenticatorToken, token) : Strings.WarningFailed); } private static async Task Response2FA(ulong steamID, string botNames) { @@ -1653,11 +1653,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private async Task Response2FAConfirm(ulong steamID, bool confirm) { @@ -1671,18 +1667,18 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } if (!HasMobileAuthenticator) { - return Strings.BotNoASFAuthenticator; + return Environment.NewLine + Strings.BotNoASFAuthenticator; } if (await AcceptConfirmations(confirm).ConfigureAwait(false)) { - return Strings.Success; + return Environment.NewLine + Strings.Success; } - return Strings.WarningFailed; + return Environment.NewLine + Strings.WarningFailed; } private static async Task Response2FAConfirm(ulong steamID, string botNames, bool confirm) { @@ -1713,11 +1709,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private async Task ResponseAddLicense(ulong steamID, ICollection gameIDs) { @@ -1731,29 +1723,29 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } - StringBuilder result = new StringBuilder(); + StringBuilder response = new StringBuilder(); foreach (uint gameID in gameIDs) { SteamApps.FreeLicenseCallback callback = await SteamApps.RequestFreeLicense(gameID); if (callback == null) { - result.AppendLine(Environment.NewLine + string.Format(Strings.BotAddLicenseResponse, BotName, gameID, EResult.Timeout)); + response.Append(Environment.NewLine + string.Format(Strings.BotAddLicenseResponse, BotName, gameID, EResult.Timeout)); break; } if (callback.GrantedApps.Count > 0) { - result.AppendLine(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, callback.Result, string.Join(", ", callback.GrantedApps))); + response.Append(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, callback.Result, string.Join(", ", callback.GrantedApps))); } else if (callback.GrantedPackages.Count > 0) { - result.AppendLine(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, callback.Result, string.Join(", ", callback.GrantedPackages))); + response.Append(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, callback.Result, string.Join(", ", callback.GrantedPackages))); } else if (await ArchiWebHandler.AddFreeLicense(gameID).ConfigureAwait(false)) { - result.AppendLine(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, EResult.OK, gameID)); + response.Append(Environment.NewLine + string.Format(Strings.BotAddLicenseResponseWithItems, BotName, gameID, EResult.OK, gameID)); } else { - result.AppendLine(Environment.NewLine + string.Format(Strings.BotAddLicenseResponse, BotName, gameID, EResult.AccessDenied)); + response.Append(Environment.NewLine + string.Format(Strings.BotAddLicenseResponse, BotName, gameID, EResult.AccessDenied)); } } - return result.ToString(); + return response.Length > 0 ? response.ToString() : null; } private async Task ResponseAddLicense(ulong steamID, string games) { @@ -1767,7 +1759,7 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } string[] gameIDs = games.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); @@ -1776,14 +1768,14 @@ namespace ArchiSteamFarm { foreach (string game in gameIDs.Where(game => !string.IsNullOrEmpty(game))) { uint gameID; if (!uint.TryParse(game, out gameID)) { - return string.Format(Strings.ErrorParsingObject, nameof(gameID)); + return Environment.NewLine + string.Format(Strings.ErrorParsingObject, nameof(gameID)); } gamesToRedeem.Add(gameID); } if (gamesToRedeem.Count == 0) { - return string.Format(Strings.ErrorIsEmpty, nameof(gamesToRedeem)); + return Environment.NewLine + string.Format(Strings.ErrorIsEmpty, nameof(gamesToRedeem)); } return await ResponseAddLicense(steamID, gamesToRedeem).ConfigureAwait(false); @@ -1817,16 +1809,12 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private static string ResponseAPI(ulong steamID) { if (steamID != 0) { - return IsOwner(steamID) ? GetAPIStatus() : null; + return IsOwner(steamID) ? Environment.NewLine + GetAPIStatus() : null; } ASF.ArchiLogger.LogNullError(nameof(steamID)); @@ -1849,7 +1837,7 @@ namespace ArchiSteamFarm { Program.Exit(); }).Forget(); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private async Task ResponseFarm(ulong steamID) { @@ -1863,12 +1851,12 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } await CardsFarmer.StopFarming().ConfigureAwait(false); CardsFarmer.StartFarming().Forget(); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private static async Task ResponseFarm(ulong steamID, string botNames) { @@ -1899,11 +1887,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private string ResponseHelp(ulong steamID) { @@ -1916,7 +1900,7 @@ namespace ArchiSteamFarm { return null; } - return "https://github.com/" + SharedInfo.GithubRepo + "/wiki/Commands"; + return Environment.NewLine + "https://github.com/" + SharedInfo.GithubRepo + "/wiki/Commands"; } private async Task ResponseLoot(ulong steamID) { @@ -1930,39 +1914,39 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } if (!LootingAllowed) { - return Strings.BotLootingTemporarilyDisabled; + return Environment.NewLine + Strings.BotLootingTemporarilyDisabled; } if (BotConfig.SteamMasterID == 0) { - return Strings.BotLootingMasterNotDefined; + return Environment.NewLine + Strings.BotLootingMasterNotDefined; } if (BotConfig.SteamMasterID == SteamClient.SteamID) { - return Strings.BotLootingYourself; + return Environment.NewLine + Strings.BotLootingYourself; } if (BotConfig.LootableTypes.Count == 0) { - return Strings.BotLootingNoLootableTypes; + return Environment.NewLine + Strings.BotLootingNoLootableTypes; } await Trading.LimitInventoryRequestsAsync().ConfigureAwait(false); HashSet inventory = await ArchiWebHandler.GetMySteamInventory(true, BotConfig.LootableTypes).ConfigureAwait(false); if ((inventory == null) || (inventory.Count == 0)) { - return string.Format(Strings.ErrorIsEmpty, nameof(inventory)); + return Environment.NewLine + string.Format(Strings.ErrorIsEmpty, nameof(inventory)); } if (!await ArchiWebHandler.SendTradeOffer(inventory, BotConfig.SteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) { - return Strings.BotLootingFailed; + return Environment.NewLine + Strings.BotLootingFailed; } await Task.Delay(3000).ConfigureAwait(false); // Sometimes we can be too fast for Steam servers to generate confirmations, wait a short moment await AcceptConfirmations(true, Steam.ConfirmationDetails.EType.Trade, BotConfig.SteamMasterID).ConfigureAwait(false); - return Strings.BotLootingSuccess; + return Environment.NewLine + Strings.BotLootingSuccess; } private static async Task ResponseLoot(ulong steamID, string botNames) { @@ -1993,11 +1977,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private string ResponseLootSwitch(ulong steamID) { @@ -2011,7 +1991,7 @@ namespace ArchiSteamFarm { } LootingAllowed = !LootingAllowed; - return LootingAllowed ? Strings.BotLootingNowEnabled : Strings.BotLootingNowDisabled; + return Environment.NewLine + (LootingAllowed ? Strings.BotLootingNowEnabled : Strings.BotLootingNowDisabled); } private static async Task ResponseLootSwitch(ulong steamID, string botNames) { @@ -2042,11 +2022,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private async Task ResponseOwns(ulong steamID, string query) { @@ -2060,7 +2036,7 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } Dictionary ownedGames; @@ -2097,11 +2073,7 @@ namespace ArchiSteamFarm { } } - if (response.Length > 0) { - return response.ToString(); - } - - return Environment.NewLine + string.Format(Strings.BotNotOwnedYet, BotName, query); + return response.Length > 0 ? response.ToString() : Environment.NewLine + string.Format(Strings.BotNotOwnedYet, BotName, query); } private static async Task ResponseOwns(ulong steamID, string botNames, string query) { @@ -2132,11 +2104,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private string ResponsePassword(ulong steamID) { @@ -2150,7 +2118,7 @@ namespace ArchiSteamFarm { } if (string.IsNullOrEmpty(BotConfig.SteamPassword)) { - return string.Format(Strings.ErrorIsEmpty, nameof(BotConfig.SteamPassword)); + return Environment.NewLine + string.Format(Strings.ErrorIsEmpty, nameof(BotConfig.SteamPassword)); } return Environment.NewLine + string.Format(Strings.BotEncryptedPassword, CryptoHelper.ECryptoMethod.AES, CryptoHelper.Encrypt(CryptoHelper.ECryptoMethod.AES, BotConfig.SteamPassword)) + Environment.NewLine + string.Format(Strings.BotEncryptedPassword, CryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, CryptoHelper.Encrypt(CryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, BotConfig.SteamPassword)); @@ -2184,11 +2152,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private async Task ResponsePause(ulong steamID, bool sticky) { @@ -2202,21 +2166,21 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } if (CardsFarmer.Paused) { - return Strings.BotAutomaticIdlingPausedAlready; + return Environment.NewLine + Strings.BotAutomaticIdlingPausedAlready; } await CardsFarmer.Pause(sticky).ConfigureAwait(false); if (!SteamFamilySharingIDs.Contains(steamID)) { - return Strings.BotAutomaticIdlingNowPaused; + return Environment.NewLine + Strings.BotAutomaticIdlingNowPaused; } StartFamilySharingInactivityTimer(); - return string.Format(Strings.BotAutomaticIdlingPausedWithCountdown, FamilySharingInactivityMinutes); + return Environment.NewLine + string.Format(Strings.BotAutomaticIdlingPausedWithCountdown, FamilySharingInactivityMinutes); } private static async Task ResponsePause(ulong steamID, string botNames, bool sticky) { @@ -2247,11 +2211,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private async Task ResponsePlay(ulong steamID, HashSet gameIDs) { @@ -2265,7 +2225,7 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } if (!CardsFarmer.Paused) { @@ -2273,7 +2233,7 @@ namespace ArchiSteamFarm { } ArchiHandler.PlayGames(gameIDs); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private async Task ResponsePlay(ulong steamID, string games) { @@ -2287,7 +2247,7 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } string[] gameIDs = games.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); @@ -2296,7 +2256,7 @@ namespace ArchiSteamFarm { foreach (string game in gameIDs.Where(game => !string.IsNullOrEmpty(game))) { uint gameID; if (!uint.TryParse(game, out gameID)) { - return string.Format(Strings.ErrorParsingObject, nameof(gameID)); + return Environment.NewLine + string.Format(Strings.ErrorParsingObject, nameof(gameID)); } gamesToPlay.Add(gameID); @@ -2307,7 +2267,7 @@ namespace ArchiSteamFarm { } if (gamesToPlay.Count == 0) { - return string.Format(Strings.ErrorIsEmpty, gamesToPlay); + return Environment.NewLine + string.Format(Strings.ErrorIsEmpty, gamesToPlay); } return await ResponsePlay(steamID, gamesToPlay).ConfigureAwait(false); @@ -2341,11 +2301,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] @@ -2360,7 +2316,7 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } bool forward = !redeemFlags.HasFlag(ERedeemFlags.SkipForwarding) && (redeemFlags.HasFlag(ERedeemFlags.ForceForwarding) || BotConfig.RedeemingPreferences.HasFlag(BotConfig.ERedeemingPreferences.Forwarding)); @@ -2530,11 +2486,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private static string ResponseRejoinChat(ulong steamID) { @@ -2551,7 +2503,7 @@ namespace ArchiSteamFarm { bot.JoinMasterChat(); } - return Strings.Done; + return Environment.NewLine + Strings.Done; } private static string ResponseRestart(ulong steamID) { @@ -2570,7 +2522,7 @@ namespace ArchiSteamFarm { Program.Restart(); }).Forget(); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private string ResponseResume(ulong steamID) { @@ -2584,16 +2536,16 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return Strings.BotNotConnected; + return Environment.NewLine + Strings.BotNotConnected; } if (!CardsFarmer.Paused) { - return Strings.BotAutomaticIdlingResumedAlready; + return Environment.NewLine + Strings.BotAutomaticIdlingResumedAlready; } StopFamilySharingInactivityTimer(); CardsFarmer.Resume(true); - return Strings.BotAutomaticIdlingNowResumed; + return Environment.NewLine + Strings.BotAutomaticIdlingNowResumed; } private static async Task ResponseResume(ulong steamID, string botNames) { @@ -2624,11 +2576,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private string ResponseStart(ulong steamID) { @@ -2642,12 +2590,12 @@ namespace ArchiSteamFarm { } if (KeepRunning) { - return Strings.BotAlreadyRunning; + return Environment.NewLine + Strings.BotAlreadyRunning; } SkipFirstShutdown = true; Start().Forget(); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private static async Task ResponseStart(ulong steamID, string botNames) { @@ -2678,11 +2626,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private static string ResponseStartAll(ulong steamID) { @@ -2699,7 +2643,7 @@ namespace ArchiSteamFarm { bot.ResponseStart(steamID); } - return Strings.Done; + return Environment.NewLine + Strings.Done; } private string ResponseStatus(ulong steamID) { @@ -2713,31 +2657,31 @@ namespace ArchiSteamFarm { } if (!IsConnectedAndLoggedOn) { - return string.Format(KeepRunning ? Strings.BotStatusNotConnected : Strings.BotStatusNotRunning, BotName); + return Environment.NewLine + string.Format(KeepRunning ? Strings.BotStatusNotConnected : Strings.BotStatusNotRunning, BotName); } if (PlayingBlocked) { - return string.Format(Strings.BotStatusPlayingNotAvailable, BotName); + return Environment.NewLine + string.Format(Strings.BotStatusPlayingNotAvailable, BotName); } if (CardsFarmer.Paused) { - return string.Format(Strings.BotStatusPaused, BotName); + return Environment.NewLine + string.Format(Strings.BotStatusPaused, BotName); } if (IsLimitedUser) { - return string.Format(Strings.BotStatusLimited, BotName); + return Environment.NewLine + string.Format(Strings.BotStatusLimited, BotName); } if (CardsFarmer.CurrentGamesFarming.Count == 0) { - return string.Format(Strings.BotsStatusNotIdling, BotName); + return Environment.NewLine + string.Format(Strings.BotsStatusNotIdling, BotName); } if (CardsFarmer.CurrentGamesFarming.Count > 1) { - return string.Format(Strings.BotStatusIdlingList, BotName, string.Join(", ", CardsFarmer.CurrentGamesFarming.Select(game => game.AppID)), CardsFarmer.GamesToFarm.Count, CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining), CardsFarmer.TimeRemaining.ToHumanReadable()); + return Environment.NewLine + string.Format(Strings.BotStatusIdlingList, BotName, string.Join(", ", CardsFarmer.CurrentGamesFarming.Select(game => game.AppID)), CardsFarmer.GamesToFarm.Count, CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining), CardsFarmer.TimeRemaining.ToHumanReadable()); } CardsFarmer.Game soloGame = CardsFarmer.CurrentGamesFarming.First(); - return string.Format(Strings.BotStatusIdling, BotName, soloGame.AppID, soloGame.GameName, soloGame.CardsRemaining, CardsFarmer.GamesToFarm.Count, CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining), CardsFarmer.TimeRemaining.ToHumanReadable()); + return Environment.NewLine + string.Format(Strings.BotStatusIdling, BotName, soloGame.AppID, soloGame.GameName, soloGame.CardsRemaining, CardsFarmer.GamesToFarm.Count, CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining), CardsFarmer.TimeRemaining.ToHumanReadable()); } private static async Task ResponseStatus(ulong steamID, string botNames) { @@ -2768,11 +2712,7 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private static string ResponseStatusAll(ulong steamID) { @@ -2788,7 +2728,7 @@ namespace ArchiSteamFarm { HashSet botsRunning = new HashSet(Bots.Where(bot => bot.Value.KeepRunning).OrderBy(bot => bot.Key).Select(bot => bot.Value)); IEnumerable statuses = botsRunning.Select(bot => bot.ResponseStatus(steamID)); - return Environment.NewLine + string.Join(Environment.NewLine, statuses) + Environment.NewLine + string.Format(Strings.BotsStatusOverview, botsRunning.Count, Bots.Count, botsRunning.Sum(bot => bot.CardsFarmer.GamesToFarm.Count), botsRunning.Sum(bot => bot.CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining))); + return string.Join("", statuses) + Environment.NewLine + string.Format(Strings.BotsStatusOverview, botsRunning.Count, Bots.Count, botsRunning.Sum(bot => bot.CardsFarmer.GamesToFarm.Count), botsRunning.Sum(bot => bot.CardsFarmer.GamesToFarm.Sum(game => game.CardsRemaining))); } private string ResponseStop(ulong steamID) { @@ -2802,11 +2742,11 @@ namespace ArchiSteamFarm { } if (!KeepRunning) { - return Strings.BotAlreadyStopped; + return Environment.NewLine + Strings.BotAlreadyStopped; } Stop(); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private static async Task ResponseStop(ulong steamID, string botNames) { @@ -2837,16 +2777,12 @@ namespace ArchiSteamFarm { } List responses = new List(results.Where(result => !string.IsNullOrEmpty(result))); - if (responses.Count == 0) { - return null; - } - - return Environment.NewLine + string.Join(Environment.NewLine, responses); + return responses.Count > 0 ? string.Join("", responses) : null; } private string ResponseUnknown(ulong steamID) { if (steamID != 0) { - return IsMaster(steamID) ? Strings.UnknownCommand : null; + return IsMaster(steamID) ? Environment.NewLine + Strings.UnknownCommand : null; } ArchiLogger.LogNullError(nameof(steamID)); @@ -2864,7 +2800,7 @@ namespace ArchiSteamFarm { } await ASF.CheckForUpdate(true).ConfigureAwait(false); - return Strings.Done; + return Environment.NewLine + Strings.Done; } private string ResponseVersion(ulong steamID) { @@ -2877,7 +2813,7 @@ namespace ArchiSteamFarm { return null; } - return "ASF V" + SharedInfo.Version; + return Environment.NewLine + "ASF V" + SharedInfo.Version; } private void SendMessageToChannel(ulong steamID, string message) { diff --git a/ArchiSteamFarm/ConcurrentHashSet.cs b/ArchiSteamFarm/ConcurrentHashSet.cs index a6ec3d626..0a65026a9 100644 --- a/ArchiSteamFarm/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/ConcurrentHashSet.cs @@ -114,16 +114,6 @@ namespace ArchiSteamFarm { } } - internal int RemoveWhere(Predicate match) { - Lock.EnterWriteLock(); - - try { - return HashSet.RemoveWhere(match); - } finally { - Lock.ExitWriteLock(); - } - } - internal bool ReplaceIfNeededWith(ICollection items) { Lock.EnterUpgradeableReadLock();