diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/BotCache.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/BotCache.cs index fbcbfb916..b33032ac7 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/BotCache.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/BotCache.cs @@ -22,7 +22,6 @@ // limitations under the License. using System; -using System.Globalization; using System.IO; using System.Text.Json.Serialization; using System.Threading.Tasks; @@ -135,7 +134,7 @@ internal sealed class BotCache : SerializableFile { string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return new BotCache(filePath); } diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs index a0b24ffe3..e4cf7bf40 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using ArchiSteamFarm.Core; @@ -87,15 +86,15 @@ internal static class Commands { } if (bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(BotConfig.ETradingPreferences.MatchEverything))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(BotConfig.ETradingPreferences.MatchEverything))); } if ((ASF.GlobalConfig?.LicenseID == null) || (ASF.GlobalConfig.LicenseID == Guid.Empty)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ASF.GlobalConfig.LicenseID))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(ASF.GlobalConfig.LicenseID))); } if (!ItemsMatcherPlugin.RemoteCommunications.TryGetValue(bot, out RemoteCommunication? remoteCommunication)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(remoteCommunication))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(remoteCommunication))); } remoteCommunication.TriggerMatchActivelyEarlier(); @@ -117,7 +116,7 @@ internal static class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => ResponseMatch(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot)))).ConfigureAwait(false); diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index 3c1a0d3ed..b7389d784 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -111,7 +111,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { TimeSpan.FromHours(6) ); } else { - bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningNoLicense, nameof(BotConfig.ETradingPreferences.MatchActively))); + bot.ArchiLogger.LogGenericError(Strings.FormatWarningNoLicense(nameof(BotConfig.ETradingPreferences.MatchActively))); } } } @@ -215,7 +215,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { // This is actually network failure, so we'll stop sending heartbeats but not record it as valid check ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForListing)}: {eligible?.ToString() ?? "null"}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(IsEligibleForListing)}: {eligible?.ToString() ?? "null"}")); return; } @@ -225,7 +225,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { LastAnnouncement = DateTime.UtcNow; ShouldSendAnnouncementEarlier = ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForListing)}: {eligible.Value}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(IsEligibleForListing)}: {eligible.Value}")); return; } @@ -242,7 +242,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { // This is actually a network failure, so we'll stop sending heartbeats but not record it as valid check ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(tradeToken))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(tradeToken))); return; } @@ -395,17 +395,17 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (setPartsResponse == null) { // This is actually a network failure, so we'll stop sending heartbeats but not record it as valid check ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(setPartsResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorObjectIsNull(nameof(setPartsResponse))); return; } if (setPartsResponse.StatusCode.IsRedirectionCode()) { ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, setPartsResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(setPartsResponse.StatusCode)); if (setPartsResponse.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(setPartsResponse.FinalUri), setPartsResponse.FinalUri)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(setPartsResponse.FinalUri), setPartsResponse.FinalUri)); return; } @@ -419,7 +419,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (!setPartsResponse.StatusCode.IsSuccessCode()) { // ArchiNet told us that we've sent a bad request, so the process should restart from the beginning at later time ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, setPartsResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(setPartsResponse.StatusCode)); switch (setPartsResponse.StatusCode) { case HttpStatusCode.Forbidden: @@ -442,7 +442,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (setPartsResponse.Content?.Result == null) { // This should never happen if we got the correct response - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(setPartsResponse), setPartsResponse.Content?.Result)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(setPartsResponse), setPartsResponse.Content?.Result)); return; } @@ -531,7 +531,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { // There is a possibility that our inventory has changed even if our announced assets did not, record that BotCache.LastInventoryChecksumBeforeDeduplication = inventoryChecksumBeforeDeduplication; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(assetsForListing)} > {MaxItemsCount}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(assetsForListing)} > {MaxItemsCount}")); return; } @@ -577,17 +577,17 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (diffResponse == null) { // This is actually a network failure, so we'll stop sending heartbeats but not record it as valid check ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(diffResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorObjectIsNull(nameof(diffResponse))); return; } if (diffResponse.StatusCode.IsRedirectionCode()) { ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, diffResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(diffResponse.StatusCode)); if (diffResponse.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(diffResponse.FinalUri), diffResponse.FinalUri)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(diffResponse.FinalUri), diffResponse.FinalUri)); return; } @@ -601,7 +601,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (!diffResponse.StatusCode.IsSuccessCode()) { // ArchiNet told us that we've sent a bad request, so the process should restart from the beginning at later time ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, diffResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(diffResponse.StatusCode)); switch (diffResponse.StatusCode) { case HttpStatusCode.Conflict: @@ -630,7 +630,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { // Great, do we need to wait? if (diffResponse.Content?.Result == null) { // This should never happen if we got the correct response - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(diffResponse), diffResponse.Content?.Result)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(diffResponse), diffResponse.Content?.Result)); return; } @@ -645,7 +645,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (diffResponse == null) { // We've waited long enough, something is definitely wrong with us or the backend - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(diffResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(diffResponse))); return; } @@ -682,17 +682,17 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (announceResponse == null) { // This is actually a network failure, so we'll stop sending heartbeats but not record it as valid check ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(announceResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorObjectIsNull(nameof(announceResponse))); return; } if (announceResponse.StatusCode.IsRedirectionCode()) { ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, announceResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(announceResponse.StatusCode)); if (announceResponse.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(announceResponse.FinalUri), announceResponse.FinalUri)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(announceResponse.FinalUri), announceResponse.FinalUri)); return; } @@ -706,7 +706,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (!announceResponse.StatusCode.IsSuccessCode()) { // ArchiNet told us that we've sent a bad request, so the process should restart from the beginning at later time ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, announceResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(announceResponse.StatusCode)); switch (announceResponse.StatusCode) { case HttpStatusCode.Conflict: @@ -735,7 +735,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { // Great, do we need to wait? if (announceResponse.Content?.Result == null) { // This should never happen if we got the correct response - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(announceResponse), announceResponse.Content?.Result)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(announceResponse), announceResponse.Content?.Result)); return; } @@ -750,7 +750,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (announceResponse == null) { // We've waited long enough, something is definitely wrong with us or the backend - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(announceResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(announceResponse))); return; } @@ -801,7 +801,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { bool? hasPublicInventory = await Bot.HasPublicInventory().ConfigureAwait(false); if (hasPublicInventory != true) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.HasPublicInventory)}: {hasPublicInventory?.ToString() ?? "null"}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(Bot.HasPublicInventory)}: {hasPublicInventory?.ToString() ?? "null"}")); return hasPublicInventory; } @@ -812,28 +812,28 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { private async Task IsEligibleForMatching() { // Bot can't be limited if (Bot.IsAccountLimited) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.IsAccountLimited)}: {Bot.IsAccountLimited}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(Bot.IsAccountLimited)}: {Bot.IsAccountLimited}")); return false; } // Bot can't be on lockdown if (Bot.IsAccountLocked) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.IsAccountLocked)}: {Bot.IsAccountLocked}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(Bot.IsAccountLocked)}: {Bot.IsAccountLocked}")); return false; } // Bot must have ASF 2FA if (!Bot.HasMobileAuthenticator) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.HasMobileAuthenticator)}: {Bot.HasMobileAuthenticator}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(Bot.HasMobileAuthenticator)}: {Bot.HasMobileAuthenticator}")); return false; } // Bot must have at least one accepted matchable type set if ((Bot.BotConfig.MatchableTypes.Count == 0) || Bot.BotConfig.MatchableTypes.All(static type => !AcceptedMatchableTypes.Contains(type))) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.BotConfig.MatchableTypes)}: {string.Join(", ", Bot.BotConfig.MatchableTypes)}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(Bot.BotConfig.MatchableTypes)}: {string.Join(", ", Bot.BotConfig.MatchableTypes)}")); return false; } @@ -842,21 +842,21 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { CCredentials_GetSteamGuardDetails_Response? steamGuardStatus = await Bot.ArchiHandler.GetSteamGuardStatus().ConfigureAwait(false); if (steamGuardStatus == null) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(steamGuardStatus)}: null")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(steamGuardStatus)}: null")); return null; } // Bot must have SteamGuard active for at least 15 days if (!steamGuardStatus.is_steamguard_enabled || ((steamGuardStatus.timestamp_steamguard_enabled > 0) && ((DateTimeOffset.UtcNow - DateTimeOffset.FromUnixTimeSeconds(steamGuardStatus.timestamp_steamguard_enabled)).TotalDays < MinimumSteamGuardEnabledDays))) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(steamGuardStatus.is_steamguard_enabled)}/{nameof(steamGuardStatus.timestamp_steamguard_enabled)}: {steamGuardStatus.is_steamguard_enabled}/{steamGuardStatus.timestamp_steamguard_enabled}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(steamGuardStatus.is_steamguard_enabled)}/{nameof(steamGuardStatus.timestamp_steamguard_enabled)}: {steamGuardStatus.is_steamguard_enabled}/{steamGuardStatus.timestamp_steamguard_enabled}")); return false; } // Bot must have 2FA enabled for matching to work if (!steamGuardStatus.is_twofactor_enabled) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(steamGuardStatus.is_twofactor_enabled)}: false")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(steamGuardStatus.is_twofactor_enabled)}: false")); return false; } @@ -864,14 +864,14 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { CCredentials_LastCredentialChangeTime_Response? credentialChangeTimeDetails = await Bot.ArchiHandler.GetCredentialChangeTimeDetails().ConfigureAwait(false); if (credentialChangeTimeDetails == null) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(credentialChangeTimeDetails)}: null")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(credentialChangeTimeDetails)}: null")); return null; } // Bot didn't change password in last 5 days if ((credentialChangeTimeDetails.timestamp_last_password_reset > 0) && ((DateTimeOffset.UtcNow - DateTimeOffset.FromUnixTimeSeconds(credentialChangeTimeDetails.timestamp_last_password_reset)).TotalDays < MinimumPasswordResetCooldownDays)) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(credentialChangeTimeDetails.timestamp_last_password_reset)}: {credentialChangeTimeDetails.timestamp_last_password_reset}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError($"{nameof(credentialChangeTimeDetails.timestamp_last_password_reset)}: {credentialChangeTimeDetails.timestamp_last_password_reset}")); return false; } @@ -897,7 +897,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { bool? eligible = await IsEligibleForMatching().ConfigureAwait(false); if (eligible != true) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForMatching)}: {eligible?.ToString() ?? "null"}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(IsEligibleForMatching)}: {eligible?.ToString() ?? "null"}")); return; } @@ -924,13 +924,13 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { HttpStatusCode? licenseStatus = await Backend.GetLicenseStatus(ASF.GlobalConfig.LicenseID.Value, WebBrowser).ConfigureAwait(false); if (licenseStatus == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(licenseStatus))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(licenseStatus))); return; } if (!licenseStatus.Value.IsSuccessCode()) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, licenseStatus.Value)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(licenseStatus.Value)); return; } @@ -941,18 +941,18 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { assetsForMatching = await Bot.ArchiHandler.GetMyInventoryAsync().Where(item => item is { AssetID: > 0, Amount: > 0, ClassID: > 0, RealAppID: > 0, Type: > EAssetType.Unknown, Rarity: > EAssetRarity.Unknown, IsSteamPointsShopItem: false } && acceptedMatchableTypes.Contains(item.Type) && !Bot.BotDatabase.MatchActivelyBlacklistAppIDs.Contains(item.RealAppID)).ToHashSetAsync().ConfigureAwait(false); } catch (TimeoutException e) { Bot.ArchiLogger.LogGenericWarningException(e); - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(assetsForMatching))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(assetsForMatching))); return; } catch (Exception e) { Bot.ArchiLogger.LogGenericException(e); - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(assetsForMatching))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(assetsForMatching))); return; } if (assetsForMatching.Count == 0) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(assetsForMatching))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatErrorIsEmpty(nameof(assetsForMatching))); return; } @@ -962,7 +962,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (assetsForMatching.RemoveWhere(item => !setsToKeep.Contains((item.RealAppID, item.Type, item.Rarity))) > 0) { if (assetsForMatching.Count == 0) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(assetsForMatching))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatErrorIsEmpty(nameof(assetsForMatching))); return; } @@ -999,16 +999,16 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (setPartsResponse == null) { // This is actually a network failure - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(setPartsResponse))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorObjectIsNull(nameof(setPartsResponse))); return; } if (setPartsResponse.StatusCode.IsRedirectionCode()) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, setPartsResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(setPartsResponse.StatusCode)); if (setPartsResponse.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(setPartsResponse.FinalUri), setPartsResponse.FinalUri)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(setPartsResponse.FinalUri), setPartsResponse.FinalUri)); return; } @@ -1020,14 +1020,14 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } if (!setPartsResponse.StatusCode.IsSuccessCode()) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, setPartsResponse.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(setPartsResponse.StatusCode)); return; } if (setPartsResponse.Content?.Result == null) { // This should never happen if we got the correct response - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(setPartsResponse), setPartsResponse.Content?.Result)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(setPartsResponse), setPartsResponse.Content?.Result)); return; } @@ -1118,13 +1118,13 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { assetsForMatching = assetsForMatchingFiltered; if (assetsForMatching.Count == 0) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(assetsForMatching))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatErrorIsEmpty(nameof(assetsForMatching))); return; } if (assetsForMatching.Count > MaxItemsCount) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(assetsForMatching)} > {MaxItemsCount}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(assetsForMatching)} > {MaxItemsCount}")); return; } @@ -1132,19 +1132,19 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { (HttpStatusCode StatusCode, ImmutableHashSet Users)? response = await Backend.GetListedUsersForMatching(ASF.GlobalConfig.LicenseID.Value, Bot, WebBrowser, assetsForMatching, acceptedMatchableTypes).ConfigureAwait(false); if (response == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(response))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(response))); return; } if (!response.Value.StatusCode.IsSuccessCode()) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Value.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.Value.StatusCode)); return; } if (response.Value.Users.IsEmpty) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(response.Value.Users))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatErrorIsEmpty(nameof(response.Value.Users))); return; } @@ -1181,7 +1181,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (MatchingUtilities.IsEmptyForMatching(ourFullState, ourTradableState)) { // User doesn't have any more dupes in the inventory - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, $"{nameof(ourFullState)} || {nameof(ourTradableState)}")); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatErrorIsEmpty($"{nameof(ourFullState)} || {nameof(ourTradableState)}")); return false; } @@ -1257,7 +1257,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderByDescending(listedUser => !deprioritizedSteamIDs.Contains(listedUser.SteamID)).ThenByDescending(static listedUser => listedUser.TotalGamesCount > 1).ThenByDescending(static listedUser => listedUser.MatchEverything).ThenBy(static listedUser => listedUser.TotalInventoryCount)) { if (failuresInRow >= WebBrowser.MaxTries) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(failuresInRow)} >= {WebBrowser.MaxTries}")); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError($"{nameof(failuresInRow)} >= {WebBrowser.MaxTries}")); break; } @@ -1280,7 +1280,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { switch (tradeHoldDuration) { case null: - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(tradeHoldDuration))); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatErrorIsEmpty(nameof(tradeHoldDuration))); continue; case > 0 when (tradeHoldDuration.Value > maxTradeHoldDuration) || (tradeHoldDuration.Value > listedUser.MaxTradeHoldDuration): @@ -1421,7 +1421,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } if (skippedSetsThisTrade.Count == 0) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(skippedSetsThisTrade))); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatErrorIsEmpty(nameof(skippedSetsThisTrade))); break; } @@ -1610,10 +1610,10 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (response.StatusCode.IsRedirectionCode()) { ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.StatusCode)); if (response.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(response.FinalUri), response.FinalUri)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(response.FinalUri), response.FinalUri)); return; } @@ -1629,7 +1629,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (!response.StatusCode.IsSuccessCode()) { ShouldSendHeartBeats = false; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.StatusCode)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.StatusCode)); switch (response.StatusCode) { case HttpStatusCode.Conflict: diff --git a/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/Commands.cs b/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/Commands.cs index 3197dfcdc..0e34718ae 100644 --- a/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/Commands.cs +++ b/ArchiSteamFarm.OfficialPlugins.MobileAuthenticator/Commands.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -100,7 +99,7 @@ internal static class Commands { } if (bot.HasMobileAuthenticator) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(bot.HasMobileAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(bot.HasMobileAuthenticator))); } if (!bot.IsConnectedAndLoggedOn) { @@ -121,17 +120,17 @@ internal static class Commands { } catch (Exception e) { bot.ArchiLogger.LogGenericException(e); - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(e.Message)); } if (string.IsNullOrEmpty(json)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + return bot.Commands.FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(json))); } Steam.Security.MobileAuthenticator? mobileAuthenticator = json.ToJsonObject(); if (mobileAuthenticator == null) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + return bot.Commands.FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(json))); } mobileAuthenticator.Init(bot); @@ -147,23 +146,23 @@ internal static class Commands { string? code = mobileAuthenticator.GenerateTokenForTime(steamTime); if (string.IsNullOrEmpty(code)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(mobileAuthenticator.GenerateTokenForTime))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(mobileAuthenticator.GenerateTokenForTime))); } CTwoFactor_FinalizeAddAuthenticator_Response? response = await mobileAuthenticatorHandler.FinalizeAuthenticator(bot.SteamID, activationCode, code, steamTime).ConfigureAwait(false); if (response == null) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(mobileAuthenticatorHandler.FinalizeAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(mobileAuthenticatorHandler.FinalizeAuthenticator))); } if (!response.success) { EResult result = (EResult) response.status; - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, result)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(result)); } if (!bot.TryImportAuthenticator(mobileAuthenticator)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(bot.TryImportAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(bot.TryImportAuthenticator))); } string maFileFinishedPath = $"{maFilePath}.NEW"; @@ -173,7 +172,7 @@ internal static class Commands { } catch (Exception e) { bot.ArchiLogger.LogGenericException(e); - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(e.Message)); } return bot.Commands.FormatBotResponse(Strings.Done); @@ -194,7 +193,7 @@ internal static class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorFinalize(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot, activationCode))).ConfigureAwait(false); @@ -216,7 +215,7 @@ internal static class Commands { } if (bot.HasMobileAuthenticator) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(bot.HasMobileAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(bot.HasMobileAuthenticator))); } string maFilePath = bot.GetFilePath(Bot.EFileType.MobileAuthenticator); @@ -233,17 +232,17 @@ internal static class Commands { } catch (Exception e) { bot.ArchiLogger.LogGenericException(e); - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(e.Message)); } if (string.IsNullOrEmpty(json)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + return bot.Commands.FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(json))); } Steam.Security.MobileAuthenticator? mobileAuthenticator = json.ToJsonObject(); if (mobileAuthenticator == null) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + return bot.Commands.FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(json))); } mobileAuthenticator.Init(bot); @@ -252,16 +251,16 @@ internal static class Commands { string? generatedCode = await mobileAuthenticator.GenerateToken().ConfigureAwait(false); if (string.IsNullOrEmpty(generatedCode)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(generatedCode))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(generatedCode))); } if (!generatedCode.Equals(activationCode, StringComparison.OrdinalIgnoreCase)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{generatedCode} != {activationCode}")); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError($"{generatedCode} != {activationCode}")); } } if (!bot.TryImportAuthenticator(mobileAuthenticator)) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(bot.TryImportAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(bot.TryImportAuthenticator))); } string maFileFinishedPath = $"{maFilePath}.NEW"; @@ -271,7 +270,7 @@ internal static class Commands { } catch (Exception e) { bot.ArchiLogger.LogGenericException(e); - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(e.Message)); } return bot.Commands.FormatBotResponse(Strings.Done); @@ -291,7 +290,7 @@ internal static class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorFinalized(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot, activationCode))).ConfigureAwait(false); @@ -313,7 +312,7 @@ internal static class Commands { } if (bot.HasMobileAuthenticator) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(bot.HasMobileAuthenticator))); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(nameof(bot.HasMobileAuthenticator))); } if (!bot.IsConnectedAndLoggedOn) { @@ -337,7 +336,7 @@ internal static class Commands { EResult result = (EResult) response.status; if (result != EResult.OK) { - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, result)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(result)); } MaFileData maFileData = new(response, bot.SteamID, deviceID); @@ -350,7 +349,7 @@ internal static class Commands { } catch (Exception e) { bot.ArchiLogger.LogGenericException(e); - return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return bot.Commands.FormatBotResponse(Strings.FormatWarningFailedWithError(e.Message)); } return bot.Commands.FormatBotResponse(Strings.Done); @@ -370,7 +369,7 @@ internal static class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? Steam.Interaction.Commands.FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorInit(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot))).ConfigureAwait(false); diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj index cd8c4b415..31e3a3ea5 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj @@ -16,6 +16,6 @@ - + diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs index e4c105adc..cc5a65827 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs @@ -77,7 +77,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC public async Task OnASFInit(IReadOnlyDictionary? additionalConfigProperties = null) { if (!SharedInfo.HasValidToken) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledMissingBuildToken, nameof(SteamTokenDumperPlugin))); + ASF.ArchiLogger.LogGenericError(Strings.FormatPluginDisabledMissingBuildToken(nameof(SteamTokenDumperPlugin))); return; } @@ -104,7 +104,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledInConfig, nameof(SteamTokenDumperPlugin))); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginDisabledInConfig(nameof(SteamTokenDumperPlugin))); return; } @@ -115,7 +115,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC GlobalCache? globalCache = await GlobalCache.Load().ConfigureAwait(false); if (globalCache == null) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.FileCouldNotBeLoadedFreshInit, nameof(GlobalCache))); + ASF.ArchiLogger.LogGenericError(Strings.FormatFileCouldNotBeLoadedFreshInit(nameof(GlobalCache))); GlobalCache = new GlobalCache(); } else { @@ -124,7 +124,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } if (!isEnabled && (config == null)) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledInConfig, nameof(SteamTokenDumperPlugin))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginDisabledInConfig(nameof(SteamTokenDumperPlugin))); return; } @@ -136,19 +136,19 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } if (!config.Enabled) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledInConfig, nameof(SteamTokenDumperPlugin))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginDisabledInConfig(nameof(SteamTokenDumperPlugin))); } if (!config.SecretAppIDs.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginSecretListInitialized, nameof(config.SecretAppIDs), string.Join(", ", config.SecretAppIDs))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginSecretListInitialized(nameof(config.SecretAppIDs), string.Join(", ", config.SecretAppIDs))); } if (!config.SecretPackageIDs.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginSecretListInitialized, nameof(config.SecretPackageIDs), string.Join(", ", config.SecretPackageIDs))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginSecretListInitialized(nameof(config.SecretPackageIDs), string.Join(", ", config.SecretPackageIDs))); } if (!config.SecretDepotIDs.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginSecretListInitialized, nameof(config.SecretDepotIDs), string.Join(", ", config.SecretDepotIDs))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginSecretListInitialized(nameof(config.SecretDepotIDs), string.Join(", ", config.SecretDepotIDs))); } Config = config; @@ -166,7 +166,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC SubmissionTimer.Change(startIn, TimeSpan.FromHours(SharedInfo.HoursBetweenUploads)); } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginInitializedAndEnabled, nameof(SteamTokenDumperPlugin), startIn.ToHumanReadable())); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginInitializedAndEnabled(nameof(SteamTokenDumperPlugin), startIn.ToHumanReadable())); } public Task OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) { @@ -362,7 +362,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC return; } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRetrievingTotalAppAccessTokens, appIDsToRefresh.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotRetrievingTotalAppAccessTokens(appIDsToRefresh.Count)); HashSet appIDsThisRound = new(Math.Min(appIDsToRefresh.Count, SharedInfo.AppInfosPerSingleRequest)); @@ -380,7 +380,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC break; } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRetrievingAppAccessTokens, appIDsThisRound.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotRetrievingAppAccessTokens(appIDsThisRound.Count)); SteamApps.PICSTokensCallback response; @@ -394,7 +394,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC continue; } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotFinishedRetrievingAppAccessTokens, appIDsThisRound.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotFinishedRetrievingAppAccessTokens(appIDsThisRound.Count)); appIDsThisRound.Clear(); @@ -402,8 +402,8 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotFinishedRetrievingTotalAppAccessTokens, appIDsToRefresh.Count)); - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRetrievingTotalDepots, appIDsToRefresh.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotFinishedRetrievingTotalAppAccessTokens(appIDsToRefresh.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotRetrievingTotalDepots(appIDsToRefresh.Count)); (_, FrozenSet? knownDepotIDs) = await GlobalCache.KnownDepotIDs.GetValue(ECacheFallback.SuccessPreviously).ConfigureAwait(false); @@ -421,7 +421,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC break; } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRetrievingAppInfos, appIDsThisRound.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotRetrievingAppInfos(appIDsThisRound.Count)); AsyncJobMultiple.ResultSet response; @@ -443,7 +443,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC continue; } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotFinishedRetrievingAppInfos, appIDsThisRound.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotFinishedRetrievingAppInfos(appIDsThisRound.Count)); appIDsThisRound.Clear(); @@ -522,7 +522,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } if (depotKeysTotal > 0) { - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotFinishedRetrievingDepotKeys, depotKeysSuccessful, depotKeysTotal)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotFinishedRetrievingDepotKeys(depotKeysSuccessful, depotKeysTotal)); } if (depotKeysSuccessful < depotKeysTotal) { @@ -534,7 +534,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC } } - bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotFinishedRetrievingTotalDepots, appIDsToRefresh.Count)); + bot.ArchiLogger.LogGenericInfo(Strings.FormatBotFinishedRetrievingTotalDepots(appIDsToRefresh.Count)); } finally { if (Config?.Enabled == true) { TimeSpan timeSpan = TimeSpan.FromHours(SharedInfo.MaximumHoursBetweenRefresh); @@ -648,7 +648,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC ulong contributorSteamID = ASF.GlobalConfig is { SteamOwnerID: > 0 } && new SteamID(ASF.GlobalConfig.SteamOwnerID).IsIndividualAccount ? ASF.GlobalConfig.SteamOwnerID : Bot.Bots.Values.Where(static bot => bot.SteamID > 0).MaxBy(static bot => bot.OwnedPackageIDs.Count)?.SteamID ?? 0; if (contributorSteamID == 0) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionNoContributorSet, nameof(ASF.GlobalConfig.SteamOwnerID))); + ASF.ArchiLogger.LogGenericError(Strings.FormatSubmissionNoContributorSet(nameof(ASF.GlobalConfig.SteamOwnerID))); return; } @@ -656,7 +656,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC Uri request = new($"{SharedInfo.ServerURL}/submit"); SubmitRequest data = new(contributorSteamID, appTokens, packageTokens, depotKeys); - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionInProgress, appTokens.Count, packageTokens.Count, depotKeys.Count)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionInProgress(appTokens.Count, packageTokens.Count, depotKeys.Count)); ObjectResponse? response = await ASF.WebBrowser.UrlPostToJsonObject(request, data: data, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors | WebBrowser.ERequestOptions.AllowInvalidBodyOnErrors, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -697,7 +697,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC SubmissionTimer.Change(startIn, TimeSpan.FromHours(SharedInfo.HoursBetweenUploads)); } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionFailedTooManyRequests, startIn.ToHumanReadable())); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionFailedTooManyRequests(startIn.ToHumanReadable())); break; } @@ -717,32 +717,32 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC return; } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessful, response.Content.Data.NewApps.Count, response.Content.Data.VerifiedApps.Count, response.Content.Data.NewPackages.Count, response.Content.Data.VerifiedPackages.Count, response.Content.Data.NewDepots.Count, response.Content.Data.VerifiedDepots.Count)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessful(response.Content.Data.NewApps.Count, response.Content.Data.VerifiedApps.Count, response.Content.Data.NewPackages.Count, response.Content.Data.VerifiedPackages.Count, response.Content.Data.NewDepots.Count, response.Content.Data.VerifiedDepots.Count)); GlobalCache.UpdateSubmittedData(appTokens, packageTokens, depotKeys); if (!response.Content.Data.NewApps.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulNewApps, string.Join(", ", response.Content.Data.NewApps))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulNewApps(string.Join(", ", response.Content.Data.NewApps))); } if (!response.Content.Data.VerifiedApps.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulVerifiedApps, string.Join(", ", response.Content.Data.VerifiedApps))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulVerifiedApps(string.Join(", ", response.Content.Data.VerifiedApps))); } if (!response.Content.Data.NewPackages.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulNewPackages, string.Join(", ", response.Content.Data.NewPackages))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulNewPackages(string.Join(", ", response.Content.Data.NewPackages))); } if (!response.Content.Data.VerifiedPackages.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulVerifiedPackages, string.Join(", ", response.Content.Data.VerifiedPackages))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulVerifiedPackages(string.Join(", ", response.Content.Data.VerifiedPackages))); } if (!response.Content.Data.NewDepots.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulNewDepots, string.Join(", ", response.Content.Data.NewDepots))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulNewDepots(string.Join(", ", response.Content.Data.NewDepots))); } if (!response.Content.Data.VerifiedDepots.IsEmpty) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.SubmissionSuccessfulVerifiedDepots, string.Join(", ", response.Content.Data.VerifiedDepots))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatSubmissionSuccessfulVerifiedDepots(string.Join(", ", response.Content.Data.VerifiedDepots))); } } finally { SubmissionSemaphore.Release(); diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index 3b6a67efc..edacba87b 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -28,7 +28,7 @@ - + diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs index 9d4b3ae56..2092dea94 100644 --- a/ArchiSteamFarm/Core/ASF.cs +++ b/ArchiSteamFarm/Core/ASF.cs @@ -493,7 +493,7 @@ public static class ASF { await Bot.RegisterBot(botName).ConfigureAwait(false); if (Bot.Bots.Count > MaximumRecommendedBotsCount) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningExcessiveBotsCount, MaximumRecommendedBotsCount)); + ArchiLogger.LogGenericWarning(Strings.FormatWarningExcessiveBotsCount(MaximumRecommendedBotsCount)); } } } @@ -679,7 +679,7 @@ public static class ASF { IEnumerable servers = await GlobalDatabase.ServerListProvider.FetchServerListAsync().ConfigureAwait(false); if (!servers.Any()) { - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.Initializing, nameof(SteamDirectory))); + ArchiLogger.LogGenericInfo(Strings.FormatInitializing(nameof(SteamDirectory))); SteamConfiguration steamConfiguration = SteamConfiguration.Create(static builder => builder.WithProtocolTypes(GlobalConfig.SteamProtocols).WithCellID(GlobalDatabase.CellID).WithServerListProvider(GlobalDatabase.ServerListProvider).WithHttpClientFactory(static () => WebBrowser.GenerateDisposableHttpClient())); @@ -708,7 +708,7 @@ public static class ASF { return; case > MaximumRecommendedBotsCount: - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningExcessiveBotsCount, MaximumRecommendedBotsCount)); + ArchiLogger.LogGenericWarning(Strings.FormatWarningExcessiveBotsCount(MaximumRecommendedBotsCount)); await Task.Delay(SharedInfo.InformationDelay).ConfigureAwait(false); break; @@ -736,7 +736,7 @@ public static class ASF { autoUpdatePeriod // Period ); - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.AutoUpdateCheckInfo, autoUpdatePeriod.ToHumanReadable())); + ArchiLogger.LogGenericInfo(Strings.FormatAutoUpdateCheckInfo(autoUpdatePeriod.ToHumanReadable())); } (bool updated, Version? newVersion) = await Update().ConfigureAwait(false); @@ -804,7 +804,7 @@ public static class ASF { Version newVersion = new(releaseResponse.Tag); - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.UpdateVersionInfo, SharedInfo.Version, newVersion)); + ArchiLogger.LogGenericInfo(Strings.FormatUpdateVersionInfo(SharedInfo.Version, newVersion)); if (!forced && (SharedInfo.Version >= newVersion)) { return (false, newVersion); @@ -857,7 +857,7 @@ public static class ASF { ArchiLogger.LogGenericInfo(releaseResponse.ChangelogPlainText); } - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.UpdateDownloadingNewVersion, newVersion, binaryAsset.Size / 1024 / 1024)); + ArchiLogger.LogGenericInfo(Strings.FormatUpdateDownloadingNewVersion(newVersion, binaryAsset.Size / 1024 / 1024)); Progress progressReporter = new(); diff --git a/ArchiSteamFarm/Core/OS.cs b/ArchiSteamFarm/Core/OS.cs index b85a96fe2..be064f9d1 100644 --- a/ArchiSteamFarm/Core/OS.cs +++ b/ArchiSteamFarm/Core/OS.cs @@ -24,7 +24,6 @@ using System; using System.ComponentModel; using System.Diagnostics; -using System.Globalization; using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -211,7 +210,7 @@ internal static class OS { } // Unknown combination, we intend to cover all of the available ones above, so this results in an error - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(SharedInfo.BuildInfo.Variant), SharedInfo.BuildInfo.Variant)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(SharedInfo.BuildInfo.Variant), SharedInfo.BuildInfo.Variant)); return false; } @@ -325,7 +324,7 @@ internal static class OS { // SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.None) in our case if (result == NativeMethods.EExecutionState.None) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, result)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(result)); } } } diff --git a/ArchiSteamFarm/Core/Utilities.cs b/ArchiSteamFarm/Core/Utilities.cs index 61c215c00..c2a8801e3 100644 --- a/ArchiSteamFarm/Core/Utilities.cs +++ b/ArchiSteamFarm/Core/Utilities.cs @@ -412,7 +412,7 @@ public static class Utilities { if (currentStringObjects.Count < defaultStringObjects.Count) { float translationCompleteness = currentStringObjects.Count / (float) defaultStringObjects.Count; - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.TranslationIncomplete, $"{CultureInfo.CurrentUICulture.Name} ({CultureInfo.CurrentUICulture.EnglishName})", translationCompleteness.ToString("P1", CultureInfo.CurrentCulture))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatTranslationIncomplete($"{CultureInfo.CurrentUICulture.Name} ({CultureInfo.CurrentUICulture.EnglishName})", translationCompleteness.ToString("P1", CultureInfo.CurrentCulture))); } } diff --git a/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs b/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs index 79753b9c5..ae86e29d5 100644 --- a/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs +++ b/ArchiSteamFarm/Helpers/ArchiCryptoHelper.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -173,7 +172,7 @@ public static class ArchiCryptoHelper { byte[] encryptionKey = Encoding.UTF8.GetBytes(key); if (encryptionKey.Length < MinimumRecommendedCryptKeyBytes) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningTooShortCryptKey, MinimumRecommendedCryptKeyBytes)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatWarningTooShortCryptKey(MinimumRecommendedCryptKeyBytes)); } HasDefaultCryptKey = encryptionKey.SequenceEqual(EncryptionKey); diff --git a/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs b/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs index c92be8479..fcbc9dfcd 100644 --- a/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs +++ b/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs @@ -23,7 +23,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -90,7 +89,7 @@ public static class JsonUtilities { if (property.AttributeProvider?.IsDefined(typeof(JsonDisallowNullAttribute), false) == true) { if (property.PropertyType.IsValueType && (Nullable.GetUnderlyingType(property.PropertyType) == null)) { // We should have no [JsonDisallowNull] declared on non-nullable types, this requires developer correction - throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(JsonDisallowNullAttribute), $"{property.Name} ({jsonTypeInfo.Type})")); + throw new InvalidOperationException(Strings.FormatWarningUnknownValuePleaseReport(nameof(JsonDisallowNullAttribute), $"{property.Name} ({jsonTypeInfo.Type})")); } potentialDisallowedNullsPossible = true; diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs index ee170f33d..807b40bcf 100644 --- a/ArchiSteamFarm/IPC/ArchiKestrel.cs +++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -166,7 +165,7 @@ internal static class ArchiKestrel { if (string.IsNullOrEmpty(physicalPath)) { // Invalid path provided - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, $"{nameof(physicalPath)} ({plugin.Name})")); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorObjectIsNull($"{nameof(physicalPath)} ({plugin.Name})")); continue; } @@ -175,7 +174,7 @@ internal static class ArchiKestrel { if (string.IsNullOrEmpty(webPath)) { // Invalid path provided - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, $"{nameof(webPath)} ({plugin.Name})")); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorObjectIsNull($"{nameof(webPath)} ({plugin.Name})")); continue; } @@ -193,7 +192,7 @@ internal static class ArchiKestrel { if (!Directory.Exists(physicalPath)) { // Non-existing path provided - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, $"{nameof(physicalPath)} ({plugin.Name})")); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid($"{nameof(physicalPath)} ({plugin.Name})")); continue; } @@ -292,7 +291,7 @@ internal static class ArchiKestrel { string[] addressParts = knownNetworkText.Split('/', 3, StringSplitOptions.RemoveEmptyEntries); if ((addressParts.Length != 2) || !IPAddress.TryParse(addressParts[0], out IPAddress? ipAddress) || !byte.TryParse(addressParts[1], out byte prefixLength)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(knownNetworkText))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(knownNetworkText))); ASF.ArchiLogger.LogGenericDebug($"{nameof(knownNetworkText)}: {knownNetworkText}"); continue; diff --git a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs index ba98e2881..3b4f12f62 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Net; using System.Text.Json; @@ -51,7 +50,7 @@ public sealed class ASFController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (string.IsNullOrEmpty(request.StringToEncrypt)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.StringToEncrypt)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(request.StringToEncrypt)))); } string? encryptedString = Actions.Encrypt(request.CryptoMethod, request.StringToEncrypt); @@ -87,7 +86,7 @@ public sealed class ASFController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (string.IsNullOrEmpty(request.StringToHash)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.StringToHash)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(request.StringToHash)))); } string hash = Actions.Hash(request.HashingMethod, request.StringToHash); @@ -144,7 +143,7 @@ public sealed class ASFController : ArchiController { if (string.IsNullOrEmpty(filePath)) { ASF.ArchiLogger.LogNullError(filePath); - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(filePath)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(filePath)))); } bool result = await GlobalConfig.Write(filePath, request.GlobalConfig).ConfigureAwait(false); @@ -183,7 +182,7 @@ public sealed class ASFController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (request.Channel.HasValue && !Enum.IsDefined(request.Channel.Value)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.Channel)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.Channel)))); } (bool success, string? message, Version? version) = await Actions.Update(request.Channel, request.Forced).ConfigureAwait(false); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index ea71147fa..ab78e4eda 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; -using System.Globalization; using System.Linq; using System.Net; using System.Text.Json; @@ -55,13 +54,13 @@ public sealed class BotController : ArchiController { ArgumentNullException.ThrowIfNull(request); if ((request.Apps?.IsEmpty != false) && (request.Packages?.IsEmpty != false)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, $"{nameof(request.Apps)} && {nameof(request.Packages)}"))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty($"{nameof(request.Apps)} && {nameof(request.Packages)}"))); } HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(bot => AddLicense(bot, request))).ConfigureAwait(false); @@ -87,7 +86,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(static bot => bot.DeleteAllRelatedFiles())).ConfigureAwait(false); @@ -107,7 +106,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if (bots == null) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(bots)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(bots)))); } return Ok(new GenericResponse>(bots.Where(static bot => !string.IsNullOrEmpty(bot.BotName)).ToDictionary(static bot => bot.BotName, static bot => bot, Bot.BotsComparer))); @@ -139,7 +138,7 @@ public sealed class BotController : ArchiController { HashSet bots = botNames.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries).ToHashSet(Bot.BotsComparer); if (bots.Any(static botName => !ASF.IsValidBotName(botName))) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(botNames)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(botNames)))); } Dictionary result = new(bots.Count, Bot.BotsComparer); @@ -177,7 +176,7 @@ public sealed class BotController : ArchiController { if (string.IsNullOrEmpty(filePath)) { ASF.ArchiLogger.LogNullError(filePath); - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(filePath)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(filePath)))); } result[botName] = await BotConfig.Write(filePath, request.BotConfig).ConfigureAwait(false); @@ -198,7 +197,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.DeleteRedeemedKeysFiles))).ConfigureAwait(false); @@ -218,7 +217,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(Dictionary? UnusedKeys, Dictionary? UsedKeys)> results = await Utilities.InParallel(bots.Select(static bot => bot.GetUsedAndUnusedKeys())).ConfigureAwait(false); @@ -245,19 +244,19 @@ public sealed class BotController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (request.GamesToRedeemInBackground.Count == 0) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.GamesToRedeemInBackground)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(request.GamesToRedeemInBackground)))); } HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IOrderedDictionary validGamesToRedeemInBackground = Bot.ValidateGamesToRedeemInBackground(request.GamesToRedeemInBackground); if (validGamesToRedeemInBackground.Count == 0) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(validGamesToRedeemInBackground)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(validGamesToRedeemInBackground)))); } await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.AddGamesToRedeemInBackground(validGamesToRedeemInBackground)))).ConfigureAwait(false); @@ -283,13 +282,13 @@ public sealed class BotController : ArchiController { ArgumentNullException.ThrowIfNull(request); if ((request.Type == ASF.EUserInputType.None) || !Enum.IsDefined(request.Type) || string.IsNullOrEmpty(request.Value)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, $"{nameof(request.Type)} || {nameof(request.Value)}"))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid($"{nameof(request.Type)} || {nameof(request.Value)}"))); } HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.SetUserInput(request.Type, request.Value)))).ConfigureAwait(false); @@ -311,7 +310,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.Pause(request.Permanent, request.ResumeInSeconds))).ConfigureAwait(false); @@ -335,13 +334,13 @@ public sealed class BotController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (request.KeysToRedeem.Count == 0) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.KeysToRedeem)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(request.KeysToRedeem)))); } HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(bot => request.KeysToRedeem.Select(key => bot.Actions.RedeemKey(key))).SelectMany(static task => task)).ConfigureAwait(false); @@ -378,11 +377,11 @@ public sealed class BotController : ArchiController { } if (string.IsNullOrEmpty(request.NewName) || !ASF.IsValidBotName(request.NewName) || Bot.Bots.ContainsKey(request.NewName)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.NewName)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.NewName)))); } if (!Bot.Bots.TryGetValue(botName, out Bot? bot)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botName))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botName))); } bool result = await bot.Rename(request.NewName).ConfigureAwait(false); @@ -402,7 +401,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.Actions.Resume))).ConfigureAwait(false); @@ -422,7 +421,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.Actions.Start))).ConfigureAwait(false); @@ -442,7 +441,7 @@ public sealed class BotController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.Actions.Stop))).ConfigureAwait(false); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs b/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs index dbad0f452..6c01e184a 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs @@ -22,7 +22,6 @@ // limitations under the License. using System; -using System.Globalization; using System.Net; using System.Threading.Tasks; using ArchiSteamFarm.Core; @@ -52,7 +51,7 @@ public sealed class CommandController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (string.IsNullOrEmpty(request.Command)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.Command)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(request.Command)))); } Bot? targetBot = Bot.GetDefaultBot(); @@ -67,7 +66,7 @@ public sealed class CommandController : ArchiController { if (!string.IsNullOrEmpty(commandPrefix) && command.StartsWith(commandPrefix, StringComparison.Ordinal)) { if (command.Length == commandPrefix.Length) { // If the message starts with command prefix and is of the same length as command prefix, then it's just empty command trigger, useless - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(command)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(command)))); } command = command[commandPrefix.Length..]; diff --git a/ArchiSteamFarm/IPC/Controllers/Api/GitHubController.cs b/ArchiSteamFarm/IPC/Controllers/Api/GitHubController.cs index f13bc00cd..58a35cf6e 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/GitHubController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/GitHubController.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Globalization; using System.Net; using System.Threading; using System.Threading.Tasks; @@ -53,7 +52,7 @@ public sealed class GitHubController : ArchiController { ReleaseResponse? releaseResponse = await GitHubService.GetLatestRelease(SharedInfo.GithubRepo, false, cancellationToken).ConfigureAwait(false); - return releaseResponse != null ? Ok(new GenericResponse(new GitHubReleaseResponse(releaseResponse))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))); + return releaseResponse != null ? Ok(new GenericResponse(new GitHubReleaseResponse(releaseResponse))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries))); } /// @@ -80,7 +79,7 @@ public sealed class GitHubController : ArchiController { break; default: if (!Version.TryParse(version, out Version? parsedVersion)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(version)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(version)))); } releaseResponse = await GitHubService.GetRelease(SharedInfo.GithubRepo, parsedVersion.ToString(4), cancellationToken).ConfigureAwait(false); @@ -88,7 +87,7 @@ public sealed class GitHubController : ArchiController { break; } - return releaseResponse != null ? Ok(new GenericResponse(new GitHubReleaseResponse(releaseResponse))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))); + return releaseResponse != null ? Ok(new GenericResponse(new GitHubReleaseResponse(releaseResponse))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries))); } /// @@ -108,7 +107,7 @@ public sealed class GitHubController : ArchiController { Dictionary? revisions = await GitHubService.GetWikiHistory(page, cancellationToken).ConfigureAwait(false); - return revisions != null ? revisions.Count > 0 ? Ok(new GenericResponse>(revisions.ToImmutableDictionary())) : BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(page)))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))); + return revisions != null ? revisions.Count > 0 ? Ok(new GenericResponse>(revisions.ToImmutableDictionary())) : BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(page)))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries))); } /// @@ -130,8 +129,8 @@ public sealed class GitHubController : ArchiController { string? html = await GitHubService.GetWikiPage(page, revision, cancellationToken).ConfigureAwait(false); return html switch { - null => StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))), - "" => BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(page)))), + null => StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries))), + "" => BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(page)))), _ => Ok(new GenericResponse(html)) }; } diff --git a/ArchiSteamFarm/IPC/Controllers/Api/IPCBansController.cs b/ArchiSteamFarm/IPC/Controllers/Api/IPCBansController.cs index 4d21e0f50..b56617745 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/IPCBansController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/IPCBansController.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Net; using ArchiSteamFarm.IPC.Integration; @@ -56,13 +55,13 @@ public sealed class IPCBansController : ArchiController { ArgumentException.ThrowIfNullOrEmpty(ipAddress); if (!IPAddress.TryParse(ipAddress, out IPAddress? remoteAddress)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(ipAddress)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(ipAddress)))); } bool result = ApiAuthenticationMiddleware.UnbanIP(remoteAddress); if (!result) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIPNotBanned, ipAddress))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIPNotBanned(ipAddress))); } return Ok(new GenericResponse(true)); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs index d5ebce27d..f2b8e7a8f 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Net; using System.Net.WebSockets; @@ -57,21 +56,21 @@ public sealed class NLogController : ArchiController { [ProducesResponseType((int) HttpStatusCode.ServiceUnavailable)] public async Task> FileGet(int count = 100, int lastAt = 0) { if (count <= 0) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(count)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(count)))); } if (lastAt < 0) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(lastAt)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(lastAt)))); } if (!Logging.LogFileExists) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(SharedInfo.LogFile)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(SharedInfo.LogFile)))); } string[]? lines = await Logging.ReadLogFileLines().ConfigureAwait(false); if ((lines == null) || (lines.Length == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(SharedInfo.LogFile)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsEmpty(nameof(SharedInfo.LogFile)))); } if ((lastAt == 0) || (lastAt > lines.Length)) { @@ -98,7 +97,7 @@ public sealed class NLogController : ArchiController { } if (!HttpContext.WebSockets.IsWebSocketRequest) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(HttpContext.WebSockets.IsWebSocketRequest)}: {HttpContext.WebSockets.IsWebSocketRequest}"))); + return BadRequest(new GenericResponse(false, Strings.FormatWarningFailedWithError($"{nameof(HttpContext.WebSockets.IsWebSocketRequest)}: {HttpContext.WebSockets.IsWebSocketRequest}"))); } // From now on we can return only EmptyResult as the response stream is already being used by existing websocket connection diff --git a/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs b/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs index d98b7d467..c3870d34b 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Net; using System.Threading.Tasks; using ArchiSteamFarm.IPC.Requests; @@ -51,7 +50,7 @@ public sealed class PluginsController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (request.Channel.HasValue && !Enum.IsDefined(request.Channel.Value)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.Channel)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.Channel)))); } (bool success, string? message) = await Actions.UpdatePlugins(request.Channel, request.Plugins, request.Forced).ConfigureAwait(false); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/StructureController.cs b/ArchiSteamFarm/IPC/Controllers/Api/StructureController.cs index 46c4f9e89..81bda514f 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/StructureController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/StructureController.cs @@ -23,7 +23,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Net; using ArchiSteamFarm.IPC.Responses; using ArchiSteamFarm.Localization; @@ -49,7 +48,7 @@ public sealed class StructureController : ArchiController { Type? targetType = WebUtilities.ParseType(structure); if (targetType == null) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, structure))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(structure))); } object? obj; @@ -57,7 +56,7 @@ public sealed class StructureController : ArchiController { try { obj = Activator.CreateInstance(targetType, true); } catch (Exception e) { - return BadRequest(new GenericResponse(false, $"{string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(targetType))}{Environment.NewLine}{e}")); + return BadRequest(new GenericResponse(false, $"{Strings.FormatErrorParsingObject(nameof(targetType))}{Environment.NewLine}{e}")); } return Ok(new GenericResponse(obj)); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs index 4935cf84b..5320b5e25 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Net; using System.Threading.Tasks; @@ -52,7 +51,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse>>>(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse>>>(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, IReadOnlyCollection? Confirmations, string Message)> results = await Utilities.InParallel(bots.Select(static bot => bot.Actions.GetConfirmations())).ConfigureAwait(false); @@ -79,13 +78,13 @@ public sealed class TwoFactorAuthenticationController : ArchiController { ArgumentNullException.ThrowIfNull(request); if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.AcceptedType)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.AcceptedType)))); } HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse>>>(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse>>>(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, IReadOnlyCollection? HandledConfirmations, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.HandleTwoFactorAuthenticationConfirmations(request.Accept, request.AcceptedType, request.AcceptedCreatorIDs.Count > 0 ? request.AcceptedCreatorIDs : null, request.WaitIfNeeded))).ConfigureAwait(false); @@ -112,7 +111,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string? Message)> results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.RemoveAuthenticator))).ConfigureAwait(false); @@ -141,7 +140,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse>>(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse>>(false, Strings.FormatBotNotFound(botNames))); } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.TryImportAuthenticator(authenticator)))).ConfigureAwait(false); @@ -168,7 +167,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return BadRequest(new GenericResponse>>(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); + return BadRequest(new GenericResponse>>(false, Strings.FormatBotNotFound(botNames))); } IList<(bool Success, string? Token, string Message)> results = await Utilities.InParallel(bots.Select(static bot => bot.Actions.GenerateTwoFactorAuthenticationToken())).ConfigureAwait(false); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/TypeController.cs b/ArchiSteamFarm/IPC/Controllers/Api/TypeController.cs index 63b517f9d..d5c7ce344 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/TypeController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/TypeController.cs @@ -54,7 +54,7 @@ public sealed class TypeController : ArchiController { Type? targetType = WebUtilities.ParseType(type); if (targetType == null) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, type))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(type))); } string? baseType = targetType.BaseType?.GetUnifiedName(); @@ -105,7 +105,7 @@ public sealed class TypeController : ArchiController { if (string.IsNullOrEmpty(valueText)) { ASF.ArchiLogger.LogNullError(valueText); - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(valueText)))); + return BadRequest(new GenericResponse(false, Strings.FormatErrorObjectIsNull(nameof(valueText)))); } string? valueObjText = Convert.ChangeType(value, enumType, CultureInfo.InvariantCulture)?.ToString(); diff --git a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs index fd86be480..19bc9bc51 100644 --- a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs @@ -75,7 +75,7 @@ public sealed class TwoFactorAuthenticationConfirmationsRequest { foreach (string creatorIDText in value) { if (!ulong.TryParse(creatorIDText, out ulong creatorID) || (creatorID == 0)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(SAcceptedCreatorIDs))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(SAcceptedCreatorIDs))); return; } diff --git a/ArchiSteamFarm/NLog/ArchiLogger.cs b/ArchiSteamFarm/NLog/ArchiLogger.cs index 66f7e612d..e5cb58983 100644 --- a/ArchiSteamFarm/NLog/ArchiLogger.cs +++ b/ArchiSteamFarm/NLog/ArchiLogger.cs @@ -117,7 +117,7 @@ public sealed class ArchiLogger { ArgumentException.ThrowIfNullOrEmpty(nullObjectName); ArgumentException.ThrowIfNullOrEmpty(previousMethodName); - LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nullObjectName), previousMethodName); + LogGenericError(Strings.FormatErrorObjectIsNull(nullObjectName), previousMethodName); } internal void LogChatMessage(bool echo, string message, ulong chatGroupID = 0, ulong chatID = 0, ulong steamID = 0, [CallerMemberName] string? previousMethodName = null) { @@ -172,7 +172,7 @@ public sealed class ArchiLogger { } // Otherwise, we ran into fatal exception before logging module could even get initialized, so activate fallback logging that involves file and console - string message = $"{DateTime.Now} {string.Format(CultureInfo.CurrentCulture, Strings.ErrorEarlyFatalExceptionInfo, SharedInfo.Version)}{Environment.NewLine}"; + string message = $"{DateTime.Now} {Strings.FormatErrorEarlyFatalExceptionInfo(SharedInfo.Version)}{Environment.NewLine}"; try { await File.WriteAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false); @@ -187,7 +187,7 @@ public sealed class ArchiLogger { } while (true) { - message = $"{string.Format(CultureInfo.CurrentCulture, Strings.ErrorEarlyFatalExceptionPrint, previousMethodName, exception.Message, exception.StackTrace)}{Environment.NewLine}"; + message = $"{Strings.FormatErrorEarlyFatalExceptionPrint(previousMethodName, exception.Message, exception.StackTrace)}{Environment.NewLine}"; try { await File.AppendAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false); diff --git a/ArchiSteamFarm/NLog/Logging.cs b/ArchiSteamFarm/NLog/Logging.cs index 0275c62a7..e234e8e93 100644 --- a/ArchiSteamFarm/NLog/Logging.cs +++ b/ArchiSteamFarm/NLog/Logging.cs @@ -23,7 +23,6 @@ using System; using System.ComponentModel; -using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -140,7 +139,7 @@ internal static class Logging { break; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(userInputType), userInputType)); return null; } diff --git a/ArchiSteamFarm/NLog/Targets/SteamTarget.cs b/ArchiSteamFarm/NLog/Targets/SteamTarget.cs index b51c1d1ca..c80d75a01 100644 --- a/ArchiSteamFarm/NLog/Targets/SteamTarget.cs +++ b/ArchiSteamFarm/NLog/Targets/SteamTarget.cs @@ -23,7 +23,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -112,7 +111,7 @@ internal sealed class SteamTarget : AsyncTaskTarget { } if (!await bot.SendMessage(ChatGroupID, SteamID, message).ConfigureAwait(false)) { - bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); + bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); } } @@ -128,7 +127,7 @@ internal sealed class SteamTarget : AsyncTaskTarget { } if (!await bot.SendMessage(SteamID, message).ConfigureAwait(false)) { - bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); + bot.ArchiLogger.LogGenericTrace(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); } } } diff --git a/ArchiSteamFarm/Plugins/Interfaces/IGitHubPluginUpdates.cs b/ArchiSteamFarm/Plugins/Interfaces/IGitHubPluginUpdates.cs index 88f54acc8..319e4ccb4 100644 --- a/ArchiSteamFarm/Plugins/Interfaces/IGitHubPluginUpdates.cs +++ b/ArchiSteamFarm/Plugins/Interfaces/IGitHubPluginUpdates.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using ArchiSteamFarm.Core; @@ -131,7 +130,7 @@ public interface IGitHubPluginUpdates : IPluginUpdates { switch (assetsByName.Count) { case 0: // Release does not have a single zip file, so the matching has failed - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newPluginVersion)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateNoAssetFound(Name, Version, newPluginVersion)); return null; case 1: @@ -146,7 +145,7 @@ public interface IGitHubPluginUpdates : IPluginUpdates { } // We can't possibly determine which zip file to use, the plugin author should either fix the release, or provide custom GetTargetReleaseAsset() implementation - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateConflictingAssetsFound, Name, Version, newPluginVersion)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateConflictingAssetsFound(Name, Version, newPluginVersion)); return null; } @@ -161,7 +160,7 @@ public interface IGitHubPluginUpdates : IPluginUpdates { } if (string.IsNullOrEmpty(RepositoryName) || (RepositoryName == SharedInfo.DefaultPluginTemplateGithubRepo)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(RepositoryName))); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(nameof(RepositoryName))); return null; } @@ -175,13 +174,13 @@ public interface IGitHubPluginUpdates : IPluginUpdates { Version newVersion = new(releaseResponse.Tag); if (!forced && (Version >= newVersion)) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNotFound, Name, Version, newVersion)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateNotFound(Name, Version, newVersion)); return null; } if (releaseResponse.Assets.Count == 0) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateNoAssetFound(Name, Version, newVersion)); return null; } @@ -189,12 +188,12 @@ public interface IGitHubPluginUpdates : IPluginUpdates { ReleaseAsset? asset = await GetTargetReleaseAsset(asfVersion, asfVariant, newVersion, releaseResponse.Assets).ConfigureAwait(false); if ((asset == null) || !releaseResponse.Assets.Contains(asset)) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateNoAssetFound(Name, Version, newVersion)); return null; } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateFound, Name, Version, newVersion)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateFound(Name, Version, newVersion)); return asset.DownloadURL; } diff --git a/ArchiSteamFarm/Plugins/PluginsCore.cs b/ArchiSteamFarm/Plugins/PluginsCore.cs index da7239eba..b248b7916 100644 --- a/ArchiSteamFarm/Plugins/PluginsCore.cs +++ b/ArchiSteamFarm/Plugins/PluginsCore.cs @@ -30,7 +30,6 @@ using System.Composition; using System.Composition.Convention; using System.Composition.Hosting; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; @@ -186,18 +185,18 @@ public static class PluginsCore { return true; } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.Initializing, nameof(Plugins))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatInitializing(nameof(Plugins))); foreach (Assembly assembly in assemblies) { if (Debugging.IsUserDebugging) { - ASF.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Initializing, assembly.FullName)); + ASF.ArchiLogger.LogGenericDebug(Strings.FormatInitializing(assembly.FullName)); } try { // This call is bare minimum to verify if the assembly can load itself assembly.GetTypes(); } catch (Exception e) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, assembly.FullName)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(assembly.FullName)); ASF.ArchiLogger.LogGenericException(e); await Task.Delay(SharedInfo.InformationDelay).ConfigureAwait(false); @@ -233,10 +232,10 @@ public static class PluginsCore { foreach (IPlugin plugin in activePlugins) { try { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginLoading, plugin.Name, plugin.Version)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginLoading(plugin.Name, plugin.Version)); if (!Program.IgnoreUnsupportedEnvironment && plugin is OfficialPlugin officialPlugin && !officialPlugin.HasSameVersion()) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnsupportedOfficialPlugins, plugin.Name, plugin.Version, SharedInfo.Version)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnsupportedOfficialPlugins(plugin.Name, plugin.Version, SharedInfo.Version)); await Task.Delay(SharedInfo.InformationDelay).ConfigureAwait(false); @@ -245,7 +244,7 @@ public static class PluginsCore { await plugin.OnLoaded().ConfigureAwait(false); - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginLoaded, plugin.Name)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginLoaded(plugin.Name)); } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); invalidPlugins.Add(plugin); @@ -290,12 +289,12 @@ public static class PluginsCore { case GlobalConfig.EPluginsUpdateMode.Whitelist when pluginsUpdateList.Contains(pluginAssemblyName): activePluginUpdates.Add(plugin); - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateEnabled, plugin.Name, pluginAssemblyName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateEnabled(plugin.Name, pluginAssemblyName)); break; case GlobalConfig.EPluginsUpdateMode.Blacklist when pluginsUpdateList.Contains(pluginAssemblyName): case GlobalConfig.EPluginsUpdateMode.Whitelist when !pluginsUpdateList.Contains(pluginAssemblyName): - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateDisabled, plugin.Name, pluginAssemblyName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateDisabled(plugin.Name, pluginAssemblyName)); break; } @@ -790,7 +789,7 @@ public static class PluginsCore { } if (skip) { - ASF.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningSkipping, assemblyPath)); + ASF.ArchiLogger.LogGenericTrace(Strings.FormatWarningSkipping(assemblyPath)); continue; } @@ -800,7 +799,7 @@ public static class PluginsCore { try { assembly = Assembly.LoadFrom(assemblyPath); } catch (Exception e) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, assemblyPath)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(assemblyPath)); ASF.ArchiLogger.LogGenericWarningException(e); continue; @@ -835,7 +834,7 @@ public static class PluginsCore { try { pluginName = plugin.Name; - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateChecking, pluginName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateChecking(pluginName)); string? assemblyDirectory = Path.GetDirectoryName(plugin.GetType().Assembly.Location); @@ -855,12 +854,12 @@ public static class PluginsCore { } if (!updateOverride && ((ASF.GlobalConfig?.UpdatePeriod ?? GlobalConfig.DefaultUpdatePeriod) == 0)) { - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNewVersionAvailable, pluginName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateNewVersionAvailable(pluginName)); return false; } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateInProgress, pluginName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateInProgress(pluginName)); Progress progressReporter = new(); @@ -901,7 +900,7 @@ public static class PluginsCore { return false; } - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateFinished, pluginName)); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateFinished(pluginName)); try { await plugin.OnPluginUpdateFinished().ConfigureAwait(false); diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index d7661d447..0453fb693 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -69,7 +69,7 @@ internal static class Program { internal static async Task Exit(byte exitCode = 0) { if (exitCode != 0) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorExitingWithNonZeroErrorCode, exitCode)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorExitingWithNonZeroErrorCode(exitCode)); } await Shutdown(exitCode).ConfigureAwait(false); @@ -110,7 +110,7 @@ internal static class Program { ArgumentException.ThrowIfNullOrEmpty(cryptKeyFile); if (!File.Exists(cryptKeyFile)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(cryptKeyFile))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(cryptKeyFile))); return false; } @@ -126,7 +126,7 @@ internal static class Program { } if (string.IsNullOrEmpty(cryptKey)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(cryptKeyFile))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(cryptKeyFile))); return false; } @@ -295,7 +295,7 @@ internal static class Program { ASF.ArchiLogger.LogGenericWarning(Strings.WarningRunningInUnsupportedEnvironment); } else { if (!OS.VerifyEnvironment()) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnsupportedEnvironment, SharedInfo.BuildInfo.Variant, OS.Version)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnsupportedEnvironment(SharedInfo.BuildInfo.Variant, OS.Version)); await Task.Delay(SharedInfo.InformationDelay).ConfigureAwait(false); return false; @@ -311,7 +311,7 @@ internal static class Program { string? cryptkey = await Logging.GetUserInput(ASF.EUserInputType.Cryptkey).ConfigureAwait(false); if (string.IsNullOrEmpty(cryptkey)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(cryptkey))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(cryptkey))); return false; } @@ -344,7 +344,7 @@ internal static class Program { (globalConfig, latestJson) = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false); if (globalConfig == null) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorGlobalConfigNotLoaded, globalConfigFile)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorGlobalConfigNotLoaded(globalConfigFile)); await Task.Delay(SharedInfo.ShortInformationDelay).ConfigureAwait(false); return false; @@ -373,7 +373,7 @@ internal static class Program { } if (!string.IsNullOrEmpty(latestJson)) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.AutomaticFileMigration, globalConfigFile)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatAutomaticFileMigration(globalConfigFile)); await SerializableFile.Write(globalConfigFile, latestJson).ConfigureAwait(false); @@ -404,7 +404,7 @@ internal static class Program { GlobalDatabase? globalDatabase = await GlobalDatabase.CreateOrLoad(globalDatabaseFile).ConfigureAwait(false); if (globalDatabase == null) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorDatabaseInvalid, globalDatabaseFile)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorDatabaseInvalid(globalDatabaseFile)); await Task.Delay(SharedInfo.ShortInformationDelay).ConfigureAwait(false); return false; @@ -647,7 +647,7 @@ internal static class Program { break; default: - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownCommandLineArgument, arg)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatWarningUnknownCommandLineArgument(arg)); break; } diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index 463fdc639..76731f643 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -216,7 +216,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } if (!Utilities.TryReadJsonWebToken(value, out JsonWebToken? accessToken)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(accessToken))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(accessToken))); return; } @@ -521,7 +521,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case BotConfig.EAccess.Master: return EAccess.Master; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(permission), permission)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(permission), permission)); return familySharingAccess; } @@ -1194,7 +1194,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { if (regionRestrictedUntil.HasValue) { // We can't play this game for now - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningRegionRestrictedPackage, appID, IPCountryCode, regionRestrictedUntil.Value)); + ArchiLogger.LogGenericWarning(Strings.FormatWarningRegionRestrictedPackage(appID, IPCountryCode, regionRestrictedUntil.Value)); return (0, regionRestrictedUntil.Value, false); } @@ -1259,7 +1259,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case "PRELOADONLY" or "PRERELEASE": return (0, DateTime.MaxValue, true); default: - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(releaseState), releaseState)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(releaseState), releaseState)); break; } @@ -1280,7 +1280,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // Types that can't be idled break; default: - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(type), type)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(type), type)); break; } @@ -1486,7 +1486,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string[] parsedArgs = line.Split(DefaultBackgroundKeysRedeemerSeparator, StringSplitOptions.RemoveEmptyEntries); if (parsedArgs.Length < 1) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, line)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid(line)); continue; } @@ -1659,7 +1659,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // The request has failed, in almost all cases this means our refresh token is no longer valid, relog needed BotDatabase.RefreshToken = RefreshToken = null; - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(SteamClient.Authentication.GenerateAccessTokenForAppAsync))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(SteamClient.Authentication.GenerateAccessTokenForAppAsync))); await Connect(true).ConfigureAwait(false); @@ -1707,7 +1707,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { (BotConfig? botConfig, string? latestJson) = await BotConfig.Load(configFilePath).ConfigureAwait(false); if (botConfig == null) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorBotConfigInvalid, configFilePath)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorBotConfigInvalid(configFilePath)); return; } @@ -1717,7 +1717,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } if (!string.IsNullOrEmpty(latestJson)) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.AutomaticFileMigration, configFilePath)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatAutomaticFileMigration(configFilePath)); await SerializableFile.Write(configFilePath, latestJson).ConfigureAwait(false); @@ -1735,7 +1735,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { BotDatabase? botDatabase = await BotDatabase.CreateOrLoad(databaseFilePath).ConfigureAwait(false); if (botDatabase == null) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorDatabaseInvalid, databaseFilePath)); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorDatabaseInvalid(databaseFilePath)); return; } @@ -1876,7 +1876,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string? input = await Logging.GetUserInput(inputType, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(input) || !SetUserInput(inputType, input)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(input))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(input))); Stop(); @@ -2070,7 +2070,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string[] parsedArgs = line.Split(DefaultBackgroundKeysRedeemerSeparator, StringSplitOptions.RemoveEmptyEntries); if (parsedArgs.Length < 3) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, line)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid(line)); continue; } @@ -2078,7 +2078,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string key = parsedArgs[^1]; if (!Utilities.IsValidCdKey(key)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, key)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid(key)); continue; } @@ -2143,7 +2143,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { private async Task HandleCallbacks() { if (!await CallbackSemaphore.WaitAsync(CallbackSleep).ConfigureAwait(false)) { if (Debugging.IsUserDebugging) { - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(CallbackSemaphore))); + ArchiLogger.LogGenericDebug(Strings.FormatWarningFailedWithError(nameof(CallbackSemaphore))); } return; @@ -2180,7 +2180,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { switch (result) { case EResult.AccountDisabled: // Those failures are permanent, we should Stop() the bot if any of those happen - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.BotUnableToLogin, result, extendedResult)); + ArchiLogger.LogGenericError(Strings.FormatBotUnableToLogin(result, extendedResult)); Stop(); @@ -2190,7 +2190,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // Likely permanently wrong account credentials LoginFailures = 0; - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.BotInvalidPasswordDuringLogin, MaxLoginFailures)); + ArchiLogger.LogGenericError(Strings.FormatBotInvalidPasswordDuringLogin(MaxLoginFailures)); Stop(); @@ -2200,7 +2200,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // Likely permanently wrong 2FA credentials that provide automatic TwoFactorAuthentication input LoginFailures = 0; - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.BotInvalidAuthenticatorDuringLogin, MaxLoginFailures)); + ArchiLogger.LogGenericError(Strings.FormatBotInvalidAuthenticatorDuringLogin(MaxLoginFailures)); Stop(); @@ -2208,7 +2208,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case EResult.AccountLoginDeniedNeedTwoFactor when HasMobileAuthenticator: case EResult.TwoFactorCodeMismatch when HasMobileAuthenticator: // Automatic TwoFactorAuthentication input provided - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.BotUnableToLogin, result, extendedResult)); + ArchiLogger.LogGenericWarning(Strings.FormatBotUnableToLogin(result, extendedResult)); // There is a possibility that our cached time is no longer appropriate, so we should reset the cache in this case in order to fetch it upon the next login attempt // Yes, this might as well be just invalid 2FA credentials, but we can't be sure about that, and we have LoginFailures designed to verify that for us @@ -2223,7 +2223,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string? authCode = await Logging.GetUserInput(ASF.EUserInputType.SteamGuard, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(authCode) || !SetUserInput(ASF.EUserInputType.SteamGuard, authCode)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(authCode))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(authCode))); Stop(); } @@ -2237,7 +2237,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string? twoFactorCode = await Logging.GetUserInput(ASF.EUserInputType.TwoFactorAuthentication, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(twoFactorCode) || !SetUserInput(ASF.EUserInputType.TwoFactorAuthentication, twoFactorCode)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(twoFactorCode))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(twoFactorCode))); Stop(); } @@ -2258,7 +2258,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case EResult.Timeout: // Usually network issues case EResult.TryAnotherCM: // Usually Steam maintenance // Generic retry pattern against common/expected problems - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.BotUnableToLogin, result, extendedResult)); + ArchiLogger.LogGenericWarning(Strings.FormatBotUnableToLogin(result, extendedResult)); break; case EResult.OK: @@ -2266,8 +2266,8 @@ public sealed class Bot : IAsyncDisposable, IDisposable { break; default: // Unexpected result, shutdown immediately - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(result), result)); - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.BotUnableToLogin, result, extendedResult)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(result), result)); + ArchiLogger.LogGenericError(Strings.FormatBotUnableToLogin(result, extendedResult)); Stop(); break; @@ -2313,7 +2313,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string json = await File.ReadAllTextAsync(maFilePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return; } @@ -2380,7 +2380,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string? steamLogin = await Logging.GetUserInput(ASF.EUserInputType.Login, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(steamLogin) || !SetUserInput(ASF.EUserInputType.Login, steamLogin)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(steamLogin))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(steamLogin))); return false; } @@ -2395,7 +2395,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string? steamPassword = await Logging.GetUserInput(ASF.EUserInputType.Password, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(steamPassword) || !SetUserInput(ASF.EUserInputType.Password, steamPassword)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(steamPassword))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(steamPassword))); return false; } @@ -2604,7 +2604,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } if (!await ArchiHandler.JoinChatRoomGroup(MasterChatGroupID).ConfigureAwait(false)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ArchiHandler.JoinChatRoomGroup))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(ArchiHandler.JoinChatRoomGroup))); } } @@ -2675,7 +2675,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { string username = GeneratedRegexes.NonAscii().Replace(BotConfig.SteamLogin, ""); if (string.IsNullOrEmpty(username)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(BotConfig.SteamLogin))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(BotConfig.SteamLogin))); Stop(); @@ -2688,7 +2688,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { password = GeneratedRegexes.NonAscii().Replace(password, ""); if (string.IsNullOrEmpty(password)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(BotConfig.SteamPassword))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(BotConfig.SteamPassword))); Stop(); @@ -2842,7 +2842,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case EResult.AccessDenied: case EResult.AccountLoginDeniedThrottle: case EResult.RateLimitExceeded: - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRateLimitExceeded, TimeSpan.FromMinutes(LoginCooldownInMinutes).ToHumanReadable())); + ArchiLogger.LogGenericInfo(Strings.FormatBotRateLimitExceeded(TimeSpan.FromMinutes(LoginCooldownInMinutes).ToHumanReadable())); if (!await ASF.LoginRateLimitingSemaphore.WaitAsync(1000 * WebBrowser.MaxTries).ConfigureAwait(false)) { break; @@ -2920,7 +2920,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { ArchiLogger.LogInvite(friend.SteamID, true); if (!await ArchiHandler.AddFriend(friend.SteamID).ConfigureAwait(false)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ArchiHandler.AddFriend))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(ArchiHandler.AddFriend))); } break; @@ -2932,7 +2932,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { ArchiLogger.LogInvite(friend.SteamID, true); if (!await ArchiHandler.AddFriend(friend.SteamID).ConfigureAwait(false)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ArchiHandler.AddFriend))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(ArchiHandler.AddFriend))); } break; @@ -2942,7 +2942,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { ArchiLogger.LogInvite(friend.SteamID, false); if (!await ArchiHandler.RemoveFriend(friend.SteamID).ConfigureAwait(false)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ArchiHandler.RemoveFriend))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(ArchiHandler.RemoveFriend))); } break; @@ -3089,7 +3089,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } if (callback.LicenseList.Count == 0) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(callback.LicenseList))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(callback.LicenseList))); return; } @@ -3173,7 +3173,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // Keep LastLogOnResult for OnDisconnected() LastLogOnResult = callback.Result > EResult.OK ? callback.Result : EResult.Invalid; - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotLoggedOff, callback.Result)); + ArchiLogger.LogGenericInfo(Strings.FormatBotLoggedOff(callback.Result)); switch (callback.Result) { case EResult.LoggedInElsewhere: @@ -3216,7 +3216,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { IPCountryCode = callback.IPCountryCode; SteamID = callback.ClientSteamID ?? throw new InvalidOperationException(nameof(callback.ClientSteamID)); - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotLoggedOn, $"{SteamID}{(!string.IsNullOrEmpty(callback.VanityURL) ? $"/{callback.VanityURL}" : "")}")); + ArchiLogger.LogGenericInfo(Strings.FormatBotLoggedOn($"{SteamID}{(!string.IsNullOrEmpty(callback.VanityURL) ? $"/{callback.VanityURL}" : "")}")); // Old status for these doesn't matter, we'll update them if needed LoginFailures = 0; @@ -3256,7 +3256,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { // We were able to automatically generate it, potentially with help of the config if (BotConfig.SteamParentalCode != steamParentalCode) { if (!SetUserInput(ASF.EUserInputType.SteamParentalCode, steamParentalCode)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(steamParentalCode))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(steamParentalCode))); Stop(); @@ -3270,7 +3270,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { steamParentalCode = await Logging.GetUserInput(ASF.EUserInputType.SteamParentalCode, BotName).ConfigureAwait(false); if (string.IsNullOrEmpty(steamParentalCode) || !SetUserInput(ASF.EUserInputType.SteamParentalCode, steamParentalCode)) { - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(steamParentalCode))); + ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(steamParentalCode))); Stop(); @@ -3308,7 +3308,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { Utilities.InBackground( async () => { if (!await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false)) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(ArchiWebHandler.JoinGroup))); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(ArchiWebHandler.JoinGroup))); } await JoinMasterChatGroupID().ConfigureAwait(false); @@ -3549,7 +3549,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { Dictionary? items = response.purchase_receipt_info.line_items.Count > 0 ? response.purchase_receipt_info.line_items.ToDictionary(static lineItem => lineItem.packageid, static lineItem => lineItem.line_item_description) : null; - ArchiLogger.LogGenericDebug(items?.Count > 0 ? string.Format(CultureInfo.CurrentCulture, Strings.BotRedeemWithItems, key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}", string.Join(", ", items)) : string.Format(CultureInfo.CurrentCulture, Strings.BotRedeem, key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}")); + ArchiLogger.LogGenericDebug(items?.Count > 0 ? Strings.FormatBotRedeemWithItems(key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}", string.Join(", ", items)) : Strings.FormatBotRedeem(key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}")); bool rateLimited = false; bool redeemed = false; @@ -3574,7 +3574,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { break; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(purchaseResultDetail), purchaseResultDetail)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(purchaseResultDetail), purchaseResultDetail)); break; } @@ -3604,14 +3604,14 @@ public sealed class Bot : IAsyncDisposable, IDisposable { await File.AppendAllTextAsync(filePath, $"{logEntry}{Environment.NewLine}").ConfigureAwait(false); } catch (Exception e) { ArchiLogger.LogGenericException(e); - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.Content, logEntry)); + ArchiLogger.LogGenericError(Strings.FormatContent(logEntry)); break; } } if (IsConnectedAndLoggedOn && BotDatabase.HasGamesToRedeemInBackground) { - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRateLimitExceeded, TimeSpan.FromHours(RedeemCooldownInHours).ToHumanReadable())); + ArchiLogger.LogGenericInfo(Strings.FormatBotRateLimitExceeded(TimeSpan.FromHours(RedeemCooldownInHours).ToHumanReadable())); GamesRedeemerInBackgroundTimer = new Timer( RedeemGamesInBackground, @@ -3658,7 +3658,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } } - ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotIdlingSelectedGames, nameof(BotConfig.GamesPlayedWhileIdle), string.Join(", ", BotConfig.GamesPlayedWhileIdle))); + ArchiLogger.LogGenericInfo(Strings.FormatBotIdlingSelectedGames(nameof(BotConfig.GamesPlayedWhileIdle), string.Join(", ", BotConfig.GamesPlayedWhileIdle))); } await ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle, BotConfig.CustomGamePlayedWhileIdle).ConfigureAwait(false); @@ -3712,7 +3712,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } if (inventory.Count == 0) { - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(inventory))); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(inventory))); return; } @@ -3794,7 +3794,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { switch (result) { case EResult.Blocked: // No point in retrying, those failures are permanent - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, result)); + ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(result)); return false; case EResult.Busy: @@ -3809,7 +3809,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case EResult.OK: return true; default: - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(result), result)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(result), result)); return false; } @@ -3913,7 +3913,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { break; default: - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(settings.passwordhashtype), settings.passwordhashtype)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(settings.passwordhashtype), settings.passwordhashtype)); return (true, null); } diff --git a/ArchiSteamFarm/Steam/Cards/CardsFarmer.cs b/ArchiSteamFarm/Steam/Cards/CardsFarmer.cs index 3ef7590f5..e341cd216 100644 --- a/ArchiSteamFarm/Steam/Cards/CardsFarmer.cs +++ b/ArchiSteamFarm/Steam/Cards/CardsFarmer.cs @@ -362,7 +362,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { byte minFarmingDelayAfterBlock = ASF.GlobalConfig?.MinFarmingDelayAfterBlock ?? GlobalConfig.DefaultMinFarmingDelayAfterBlock; if (minFarmingDelayAfterBlock > 0) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotExtraIdlingCooldown, TimeSpan.FromSeconds(minFarmingDelayAfterBlock).ToHumanReadable())); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatBotExtraIdlingCooldown(TimeSpan.FromSeconds(minFarmingDelayAfterBlock).ToHumanReadable())); for (byte i = 0; (i < minFarmingDelayAfterBlock) && Bot is { IsConnectedAndLoggedOn: true, IsPlayingPossible: true, PlayingWasBlocked: true }; i++) { await Task.Delay(1000).ConfigureAwait(false); @@ -430,7 +430,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { Game? game = await GetGameCardsInfo(appID).ConfigureAwait(false); if (game == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningCouldNotCheckCardsStatus, appID, name)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningCouldNotCheckCardsStatus(appID, name)); return; } @@ -671,7 +671,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { if (privateAppIDs?.Contains(appID) == true) { // This game is private, it won't drop any cards until removal - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingGameNotPossiblePrivate, appID, name)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingGameNotPossiblePrivate(appID, name)); continue; } @@ -772,12 +772,12 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { private async Task Farm() { do { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(static game => game.CardsRemaining), TimeRemaining.ToHumanReadable())); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatGamesToIdle(GamesToFarm.Count, GamesToFarm.Sum(static game => game.CardsRemaining), TimeRemaining.ToHumanReadable())); // Now the algorithm used for farming depends on whether account is restricted or not if (Bot.BotConfig.HoursUntilCardDrops > 0) { // If we have restricted card drops, we use complex algorithm - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ChosenFarmingAlgorithm, "Complex")); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatChosenFarmingAlgorithm("Complex")); while (GamesToFarm.Count > 0) { // Initially we're going to farm games that passed our HoursUntilCardDrops @@ -833,7 +833,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { // Otherwise, we farm our innerGamesToFarm batch until any game hits HoursUntilCardDrops if (await FarmMultiple(innerGamesToFarm).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingFinishedForGames, string.Join(", ", innerGamesToFarm.Select(static game => game.AppID)))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingFinishedForGames(string.Join(", ", innerGamesToFarm.Select(static game => game.AppID)))); } else { NowFarming = false; @@ -844,7 +844,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { } } else { // If we have unrestricted card drops, we use simple algorithm - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ChosenFarmingAlgorithm, "Simple")); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatChosenFarmingAlgorithm("Simple")); while (GamesToFarm.Count > 0) { // In simple algorithm we're going to farm anything that is playable, regardless of hours @@ -877,7 +877,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { ArgumentNullException.ThrowIfNull(game); if (game.AppID != game.PlayableAppID) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningIdlingGameMismatch, game.AppID, game.GameName, game.PlayableAppID)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningIdlingGameMismatch(game.AppID, game.GameName, game.PlayableAppID)); } await Bot.IdleGame(game).ConfigureAwait(false); @@ -886,7 +886,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { DateTime endFarmingDate = DateTime.UtcNow.AddHours(ASF.GlobalConfig?.MaxFarmingTime ?? GlobalConfig.DefaultMaxFarmingTime); while ((DateTime.UtcNow < endFarmingDate) && (await ShouldFarm(game).ConfigureAwait(false)).GetValueOrDefault(true)) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.StillIdling, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatStillIdling(game.AppID, game.GameName)); DateTime startFarmingPeriod = DateTime.UtcNow; @@ -915,7 +915,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { } } - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.StoppedIdling, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatStoppedIdling(game.AppID, game.GameName)); return keepFarming; } @@ -934,7 +934,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { } if (maxHour >= Bot.BotConfig.HoursUntilCardDrops) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(maxHour))); + Bot.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(maxHour))); return true; } @@ -944,7 +944,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { bool keepFarming = true; while (maxHour < Bot.BotConfig.HoursUntilCardDrops) { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.StillIdlingList, string.Join(", ", games.Select(static game => game.AppID)))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatStillIdlingList(string.Join(", ", games.Select(static game => game.AppID)))); DateTime startFarmingPeriod = DateTime.UtcNow; @@ -974,7 +974,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { maxHour += timePlayed; } - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.StoppedIdlingList, string.Join(", ", games.Select(static game => game.AppID)))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatStoppedIdlingList(string.Join(", ", games.Select(static game => game.AppID)))); return keepFarming; } @@ -988,9 +988,9 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { if (games.Count == 1) { Game game = games.First(); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.NowIdling, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatNowIdling(game.AppID, game.GameName)); } else { - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.NowIdlingList, string.Join(", ", games.Select(static game => game.AppID)))); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatNowIdlingList(string.Join(", ", games.Select(static game => game.AppID)))); } bool result = await FarmHours(games).ConfigureAwait(false); @@ -1004,7 +1004,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { CurrentGamesFarming.Add(game); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.NowIdling, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatNowIdling(game.AppID, game.GameName)); bool result = await FarmCards(game).ConfigureAwait(false); CurrentGamesFarming.Clear(); @@ -1015,7 +1015,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { GamesToFarm.Remove(game); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingFinishedForGame, game.AppID, game.GameName, TimeSpan.FromHours(game.HoursPlayed).ToHumanReadable())); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingFinishedForGame(game.AppID, game.GameName, TimeSpan.FromHours(game.HoursPlayed).ToHumanReadable())); return true; } @@ -1291,7 +1291,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { } // This game is private, it won't drop any cards until removal - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingGameNotPossiblePrivate, appID, name)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingGameNotPossiblePrivate(appID, name)); gamesToFarm.Remove(appID); } @@ -1361,7 +1361,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { ConcurrentDictionary ignoredAppIDs = ignoredGlobally ? GloballyIgnoredAppIDs : LocallyIgnoredAppIDs; ignoredAppIDs[game.AppID] = (ignoredUntil > DateTime.MinValue) && (ignoredUntil < DateTime.MaxValue) ? ignoredUntil : DateTime.UtcNow.AddHours(HoursToIgnore); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingGameNotPossible, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingGameNotPossible(game.AppID, game.GameName)); return false; } @@ -1377,14 +1377,14 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { Game? latestGameData = await GetGameCardsInfo(game.AppID).ConfigureAwait(false); if (latestGameData == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningCouldNotCheckCardsStatus, game.AppID, game.GameName)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningCouldNotCheckCardsStatus(game.AppID, game.GameName)); return null; } game.CardsRemaining = latestGameData.CardsRemaining; - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IdlingStatusForGame, game.AppID, game.GameName, game.CardsRemaining)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIdlingStatusForGame(game.AppID, game.GameName, game.CardsRemaining)); if (game.CardsRemaining == 0) { Bot.BotDatabase.FarmingRiskyIgnoredAppIDs[game.AppID] = DateTime.UtcNow.AddDays(DaysToIgnoreRiskyAppIDs); @@ -1527,7 +1527,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable { break; default: - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(farmingOrder), farmingOrder)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(farmingOrder), farmingOrder)); return; } diff --git a/ArchiSteamFarm/Steam/Data/InventoryDescription.cs b/ArchiSteamFarm/Steam/Data/InventoryDescription.cs index 13de996c9..243f75220 100644 --- a/ArchiSteamFarm/Steam/Data/InventoryDescription.cs +++ b/ArchiSteamFarm/Steam/Data/InventoryDescription.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Immutable; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Text.Json.Serialization; using ArchiSteamFarm.Core; @@ -208,7 +207,7 @@ public sealed class InventoryDescription { return CachedRarity.Value; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(tag.internal_name), tag.internal_name)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(tag.internal_name), tag.internal_name)); CachedRarity = EAssetRarity.Unknown; @@ -261,7 +260,7 @@ public sealed class InventoryDescription { switch (tag.category) { case "Game": if (string.IsNullOrEmpty(tag.internal_name) || (tag.internal_name.Length <= 4) || !tag.internal_name.StartsWith("app_", StringComparison.Ordinal)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(tag.internal_name), tag.internal_name)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(tag.internal_name), tag.internal_name)); break; } @@ -359,7 +358,7 @@ public sealed class InventoryDescription { return CachedType.Value; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(tag.internal_name), tag.internal_name)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(tag.internal_name), tag.internal_name)); CachedType = EAssetType.Unknown; @@ -431,7 +430,7 @@ public sealed class InventoryDescription { return CachedType.Value; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(tag.internal_name), tag.internal_name)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(tag.internal_name), tag.internal_name)); CachedType = EAssetType.Unknown; diff --git a/ArchiSteamFarm/Steam/Exchange/Trading.cs b/ArchiSteamFarm/Steam/Exchange/Trading.cs index 709f36ee6..77c081563 100644 --- a/ArchiSteamFarm/Steam/Exchange/Trading.cs +++ b/ArchiSteamFarm/Steam/Exchange/Trading.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -321,7 +320,7 @@ public sealed class Trading : IDisposable { switch (result) { case ParseTradeResult.EResult.Accepted: - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.AcceptingTrade, tradeOffer.TradeOfferID)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatAcceptingTrade(tradeOffer.TradeOfferID)); (bool success, bool requiresMobileConfirmation) = await Bot.ArchiWebHandler.AcceptTradeOffer(tradeOffer.TradeOfferID).ConfigureAwait(false); @@ -335,7 +334,7 @@ public sealed class Trading : IDisposable { HandledTradeOfferIDs.Remove(tradeOffer.TradeOfferID); if (tradeOffer.ItemsToReceive.Sum(static item => item.Amount) > tradeOffer.ItemsToGive.Sum(static item => item.Amount)) { - Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.BotAcceptedDonationTrade, tradeOffer.TradeOfferID)); + Bot.ArchiLogger.LogGenericTrace(Strings.FormatBotAcceptedDonationTrade(tradeOffer.TradeOfferID)); } tradeRequiresMobileConfirmation = requiresMobileConfirmation; @@ -343,7 +342,7 @@ public sealed class Trading : IDisposable { break; case ParseTradeResult.EResult.Blacklisted: case ParseTradeResult.EResult.Rejected when Bot.BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.RejectInvalidTrades): - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.RejectingTrade, tradeOffer.TradeOfferID)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatRejectingTrade(tradeOffer.TradeOfferID)); if (!await Bot.ArchiWebHandler.DeclineTradeOffer(tradeOffer.TradeOfferID).ConfigureAwait(false)) { result = ParseTradeResult.EResult.TryAgain; @@ -358,7 +357,7 @@ public sealed class Trading : IDisposable { case ParseTradeResult.EResult.Ignored: case ParseTradeResult.EResult.Rejected: // We expect to see this trade offer in the future, so we keep it in HandledTradeOfferIDs if it wasn't removed as part of other result - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.IgnoringTrade, tradeOffer.TradeOfferID)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatIgnoringTrade(tradeOffer.TradeOfferID)); break; case ParseTradeResult.EResult.TryAgain: @@ -367,7 +366,7 @@ public sealed class Trading : IDisposable { goto case ParseTradeResult.EResult.Ignored; default: - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(result), result)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(result), result)); return new ParseTradeResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Ignored, false, tradeOffer.ItemsToGive, tradeOffer.ItemsToReceive); } @@ -385,14 +384,14 @@ public sealed class Trading : IDisposable { if (tradeOffer.OtherSteamID64 != 0) { // Always deny trades from blacklisted steamIDs if (Bot.IsBlacklistedFromTrades(tradeOffer.OtherSteamID64)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Blacklisted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Blacklisted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}")); return ParseTradeResult.EResult.Blacklisted; } // Always accept trades from SteamMasterID if (Bot.GetAccess(tradeOffer.OtherSteamID64) >= EAccess.Master) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}: {BotConfig.EAccess.Master}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}: {BotConfig.EAccess.Master}")); return ParseTradeResult.EResult.Accepted; } @@ -405,7 +404,7 @@ public sealed class Trading : IDisposable { bool? isBadBot = await ArchiNet.IsBadBot(tradeOffer.OtherSteamID64, archiNetCancellation.Token).ConfigureAwait(false); if (isBadBot == true) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Blacklisted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Blacklisted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}")); return ParseTradeResult.EResult.Blacklisted; } @@ -416,7 +415,7 @@ public sealed class Trading : IDisposable { switch (tradeOffer.ItemsToGive.Count) { case 0 when tradeOffer.ItemsToReceive.Count == 0: // If it's steam issue, try again later - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, $"{nameof(tradeOffer.ItemsToReceive.Count)} = 0")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, $"{nameof(tradeOffer.ItemsToReceive.Count)} = 0")); return ParseTradeResult.EResult.TryAgain; case 0: @@ -427,13 +426,13 @@ public sealed class Trading : IDisposable { switch (acceptDonations) { case true when acceptBotTrades: // If we accept donations and bot trades, accept it right away - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(acceptDonations)} = {true} && {nameof(acceptBotTrades)} = {true}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(acceptDonations)} = {true} && {nameof(acceptBotTrades)} = {true}")); return ParseTradeResult.EResult.Accepted; case false when !acceptBotTrades: // If we don't accept donations, neither bot trades, deny it right away - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(acceptDonations)} = {false} && {nameof(acceptBotTrades)} = {false}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(acceptDonations)} = {false} && {nameof(acceptBotTrades)} = {false}")); return ParseTradeResult.EResult.Rejected; } @@ -443,28 +442,28 @@ public sealed class Trading : IDisposable { ParseTradeResult.EResult result = (acceptDonations && !isBotTrade) || (acceptBotTrades && isBotTrade) ? ParseTradeResult.EResult.Accepted : ParseTradeResult.EResult.Rejected; - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, result, $"{nameof(acceptDonations)} = {acceptDonations} && {nameof(acceptBotTrades)} = {acceptBotTrades} && {nameof(isBotTrade)} = {isBotTrade}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, result, $"{nameof(acceptDonations)} = {acceptDonations} && {nameof(acceptBotTrades)} = {acceptBotTrades} && {nameof(isBotTrade)} = {isBotTrade}")); return result; } // If we don't have SteamTradeMatcher enabled, this is the end for us if (!Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(BotConfig.ETradingPreferences.SteamTradeMatcher)} = {false}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(BotConfig.ETradingPreferences.SteamTradeMatcher)} = {false}")); return ParseTradeResult.EResult.Rejected; } // Decline trade if we're giving more count-wise, this is a very naive pre-check, it'll be strengthened in more detailed fair types exchange next if (tradeOffer.ItemsToGive.Count > tradeOffer.ItemsToReceive.Count) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(tradeOffer.ItemsToGive.Count)}: {tradeOffer.ItemsToGive.Count} > {tradeOffer.ItemsToReceive.Count}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(tradeOffer.ItemsToGive.Count)}: {tradeOffer.ItemsToGive.Count} > {tradeOffer.ItemsToReceive.Count}")); return ParseTradeResult.EResult.Rejected; } // Decline trade if we're requested to handle any not-accepted item type or if it's not fair games/types exchange if (!tradeOffer.IsValidSteamItemsRequest(Bot.BotConfig.MatchableTypes) || !IsFairExchange(tradeOffer.ItemsToGive, tradeOffer.ItemsToReceive)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(tradeOffer.IsValidSteamItemsRequest)} || {nameof(IsFairExchange)}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(tradeOffer.IsValidSteamItemsRequest)} || {nameof(IsFairExchange)}")); return ParseTradeResult.EResult.Rejected; } @@ -477,21 +476,21 @@ public sealed class Trading : IDisposable { switch (holdDuration) { case null: // If we can't get trade hold duration, try again later - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(holdDuration))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(holdDuration))); return ParseTradeResult.EResult.TryAgain; // If user has a trade hold, we add extra logic // If trade hold duration exceeds our max, or user asks for cards with short lifespan, reject the trade case > 0 when (holdDuration.Value > (ASF.GlobalConfig?.MaxTradeHoldDuration ?? GlobalConfig.DefaultMaxTradeHoldDuration)) || tradeOffer.ItemsToGive.Any(static item => item.Type is EAssetType.FoilTradingCard or EAssetType.TradingCard && CardsFarmer.SalesBlacklist.Contains(item.RealAppID)): - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(holdDuration)} > 0: {holdDuration.Value}")); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Rejected, $"{nameof(holdDuration)} > 0: {holdDuration.Value}")); return ParseTradeResult.EResult.Rejected; } // If we're matching everything, this is enough for us if (Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, BotConfig.ETradingPreferences.MatchEverything)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, BotConfig.ETradingPreferences.MatchEverything)); return ParseTradeResult.EResult.Accepted; } @@ -507,21 +506,21 @@ public sealed class Trading : IDisposable { } catch (TimeoutException e) { // If we can't check our inventory when not using MatchEverything, this is a temporary failure, try again later Bot.ArchiLogger.LogGenericWarningException(e); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); return ParseTradeResult.EResult.TryAgain; } catch (Exception e) { // If we can't check our inventory when not using MatchEverything, this is a temporary failure, try again later Bot.ArchiLogger.LogGenericException(e); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); return ParseTradeResult.EResult.TryAgain; } if (inventory.Count == 0) { // If we can't check our inventory when not using MatchEverything, this is a temporary failure, try again later - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(inventory))); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(inventory))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.TryAgain, nameof(inventory))); return ParseTradeResult.EResult.TryAgain; } @@ -531,7 +530,7 @@ public sealed class Trading : IDisposable { // We're now sure whether the trade is neutral+ for us or not ParseTradeResult.EResult acceptResult = accept ? ParseTradeResult.EResult.Accepted : ParseTradeResult.EResult.Rejected; - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, acceptResult, nameof(IsTradeNeutralOrBetter))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatBotTradeOfferResult(tradeOffer.TradeOfferID, acceptResult, nameof(IsTradeNeutralOrBetter))); return acceptResult; } diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 95c8df4ee..f16492371 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using ArchiSteamFarm.Core; @@ -180,7 +179,7 @@ public sealed class ArchiHandler : ClientMsgHandler { ArgumentOutOfRangeException.ThrowIfZero(itemsCountPerRequest); if (!Client.IsConnected || (Client.SteamID == null)) { - throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Client.IsConnected))); + throw new TimeoutException(Strings.FormatWarningFailedWithError(nameof(Client.IsConnected))); } ulong steamID = Client.SteamID; @@ -240,21 +239,21 @@ public sealed class ArchiHandler : ClientMsgHandler { continue; case EResult.NoMatch: // Expected failures that we're not going to retry - throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, serviceMethodResponse.Result)); + throw new TimeoutException(Strings.FormatWarningFailedWithError(serviceMethodResponse.Result)); default: // Unknown failures, report them and do not retry since we're unsure if we should - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(serviceMethodResponse.Result), serviceMethodResponse.Result)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(serviceMethodResponse.Result), serviceMethodResponse.Result)); - throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, serviceMethodResponse.Result)); + throw new TimeoutException(Strings.FormatWarningFailedWithError(serviceMethodResponse.Result)); } } if (serviceMethodResponse == null) { - throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(serviceMethodResponse))); + throw new TimeoutException(Strings.FormatErrorObjectIsNull(nameof(serviceMethodResponse))); } if (serviceMethodResponse.Result != EResult.OK) { - throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, serviceMethodResponse.Result)); + throw new TimeoutException(Strings.FormatWarningFailedWithError(serviceMethodResponse.Result)); } CEcon_GetInventoryItemsWithDescriptions_Response response = serviceMethodResponse.GetDeserializedResponse(); @@ -283,7 +282,7 @@ public sealed class ArchiHandler : ClientMsgHandler { foreach (CEconItem_Description? description in response.descriptions) { if (description.classid == 0) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(description.classid))); + throw new NotSupportedException(Strings.FormatErrorObjectIsNull(nameof(description.classid))); } (ulong ClassID, ulong InstanceID) key = (description.classid, description.instanceid); @@ -311,7 +310,7 @@ public sealed class ArchiHandler : ClientMsgHandler { } if (response.last_assetid == 0) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response.last_assetid))); + throw new NotSupportedException(Strings.FormatErrorObjectIsNull(nameof(response.last_assetid))); } request.start_assetid = response.last_assetid; diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index c78aedbd8..6e4c5b692 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -253,7 +253,7 @@ public sealed class ArchiWebHandler : IDisposable { steamID = Bot.SteamID; } else if (!new SteamID(steamID).IsIndividualAccount) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(steamID))); + throw new NotSupportedException(Strings.FormatErrorObjectIsNull(nameof(steamID))); } if (ASF.InventorySemaphore == null) { @@ -285,11 +285,11 @@ public sealed class ArchiWebHandler : IDisposable { response = await UrlGetToJsonObjectWithSession(request, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors | WebBrowser.ERequestOptions.ReturnServerErrors | WebBrowser.ERequestOptions.AllowInvalidBodyOnErrors, rateLimitingDelay: rateLimitingDelay).ConfigureAwait(false); if (response == null) { - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response))); + throw new HttpRequestException(Strings.FormatErrorObjectIsNull(nameof(response))); } if (response.StatusCode.IsClientErrorCode()) { - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.StatusCode), null, response.StatusCode); + throw new HttpRequestException(Strings.FormatWarningFailedWithError(response.StatusCode), null, response.StatusCode); } if (response.StatusCode.IsServerErrorCode()) { @@ -298,7 +298,7 @@ public sealed class ArchiWebHandler : IDisposable { continue; } - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.ErrorText)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningFailedWithError(response.Content.ErrorText)); // Try to interpret the failure reason and see if we should try again switch (response.Content.ErrorCode) { @@ -312,12 +312,12 @@ public sealed class ArchiWebHandler : IDisposable { continue; case EResult.NoMatch: // Expected failures that we're not going to retry - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.ErrorText), null, response.StatusCode); + throw new HttpRequestException(Strings.FormatWarningFailedWithError(response.Content.ErrorText), null, response.StatusCode); default: // Unknown failures, report them and do not retry since we're unsure if we should - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(response.Content.ErrorText), response.Content.ErrorText)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(response.Content.ErrorText), response.Content.ErrorText)); - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.ErrorText), null, response.StatusCode); + throw new HttpRequestException(Strings.FormatWarningFailedWithError(response.Content.ErrorText), null, response.StatusCode); } } } @@ -335,11 +335,11 @@ public sealed class ArchiWebHandler : IDisposable { } if (response == null) { - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response))); + throw new HttpRequestException(Strings.FormatErrorObjectIsNull(nameof(response))); } if (response.Content is not { Result: EResult.OK } || !response.StatusCode.IsSuccessCode()) { - throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content?.ErrorText ?? response.Content?.Result?.ToString() ?? response.StatusCode.ToString())); + throw new HttpRequestException(Strings.FormatWarningFailedWithError(response.Content?.ErrorText ?? response.Content?.Result?.ToString() ?? response.StatusCode.ToString())); } if ((response.Content.TotalInventoryCount == 0) || (response.Content.Assets.Count == 0)) { @@ -366,7 +366,7 @@ public sealed class ArchiWebHandler : IDisposable { foreach (InventoryDescription description in response.Content.Descriptions) { if (description.ClassID == 0) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(description.ClassID))); + throw new NotSupportedException(Strings.FormatErrorObjectIsNull(nameof(description.ClassID))); } (ulong ClassID, ulong InstanceID) key = (description.ClassID, description.InstanceID); @@ -387,7 +387,7 @@ public sealed class ArchiWebHandler : IDisposable { } if (response.Content.LastAssetID == 0) { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response.Content.LastAssetID))); + throw new NotSupportedException(Strings.FormatErrorObjectIsNull(nameof(response.Content.LastAssetID))); } startAssetID = response.Content.LastAssetID; @@ -433,7 +433,7 @@ public sealed class ArchiWebHandler : IDisposable { } if (response == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); return null; } @@ -503,7 +503,7 @@ public sealed class ArchiWebHandler : IDisposable { TradeOffersResponse? response = (await WebLimitRequest(WebAPI.DefaultBaseAddress, async () => await WebBrowser.UrlGetToJsonObject>(request).ConfigureAwait(false)).ConfigureAwait(false))?.Content?.Response; if (response == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); return null; } @@ -664,7 +664,7 @@ public sealed class ArchiWebHandler : IDisposable { } // This is actually client error with a reason, so it doesn't make sense to retry - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.ErrorText)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.Content.ErrorText)); return (false, tradeOfferIDs, mobileTradeOfferIDs); } @@ -710,7 +710,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -729,7 +729,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -750,18 +750,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -792,7 +792,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -811,7 +811,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return default(ObjectResponse?); } @@ -832,18 +832,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -874,7 +874,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -893,7 +893,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -914,18 +914,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -961,7 +961,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -980,7 +980,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1024,18 +1024,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1071,7 +1071,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1090,7 +1090,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1134,18 +1134,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1181,7 +1181,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1200,7 +1200,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1247,18 +1247,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -1294,7 +1294,7 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -1313,7 +1313,7 @@ public sealed class ArchiWebHandler : IDisposable { if (!Initialized) { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -1357,18 +1357,18 @@ public sealed class ArchiWebHandler : IDisposable { } Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (!requestOptions.HasFlag(WebBrowser.ERequestOptions.ReturnRedirections) && await IsProfileUri(response.FinalUri).ConfigureAwait(false) && !await IsProfileUri(request).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); if (--maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -1397,7 +1397,7 @@ public sealed class ArchiWebHandler : IDisposable { } if (!ASF.WebLimitingSemaphores.TryGetValue(service, out (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim OpenConnectionsSemaphore) limiters)) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(service), service)); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatWarningUnknownValuePleaseReport(nameof(service), service)); limiters.RateLimitingSemaphore = ASF.RateLimitingSemaphore; limiters.OpenConnectionsSemaphore = ASF.OpenConnectionsSemaphore; @@ -1482,7 +1482,7 @@ public sealed class ArchiWebHandler : IDisposable { } // This is actually client error with a reason, so it doesn't make sense to retry - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.ErrorText)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.Content.ErrorText)); return (false, false); } @@ -1540,7 +1540,7 @@ public sealed class ArchiWebHandler : IDisposable { case "You got rate limited, try again in an hour.": return (result, EPurchaseResultDetail.RateLimited); default: - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorMessage), errorMessage)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(errorMessage), errorMessage)); return (result, EPurchaseResultDetail.ContactSupport); } @@ -1554,7 +1554,7 @@ public sealed class ArchiWebHandler : IDisposable { return (EResult.AccessDenied, EPurchaseResultDetail.NoDetail); default: // We should handle all expected status codes above, this is a generic fallback for those that we don't - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(response.StatusCode), response.StatusCode)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(response.StatusCode), response.StatusCode)); return (response.StatusCode.IsSuccessCode() ? EResult.OK : EResult.Fail, EPurchaseResultDetail.ContactSupport); } @@ -1653,7 +1653,7 @@ public sealed class ArchiWebHandler : IDisposable { } if (response == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); return null; } @@ -1661,7 +1661,7 @@ public sealed class ArchiWebHandler : IDisposable { List apps = response["apps"].Children; if (apps.Count == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(apps))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(apps))); return null; } @@ -1768,7 +1768,7 @@ public sealed class ArchiWebHandler : IDisposable { } if (response == null) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); return null; } @@ -1840,13 +1840,13 @@ public sealed class ArchiWebHandler : IDisposable { } if (giftCardIDText.Length <= 13) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(giftCardIDText))); + Bot.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(giftCardIDText))); return null; } if (!ulong.TryParse(giftCardIDText[13..], out ulong giftCardID) || (giftCardID == 0)) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(giftCardID))); + Bot.ArchiLogger.LogGenericError(Strings.FormatErrorParsingObject(nameof(giftCardID))); return null; } @@ -2353,8 +2353,8 @@ public sealed class ArchiWebHandler : IDisposable { Uri request = new(service, "/parental/ajaxunlock"); if (maxTries == 0) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return false; } @@ -2382,7 +2382,7 @@ public sealed class ArchiWebHandler : IDisposable { // Under special brain-damaged circumstances, Steam might just return our own profile as a response to the request, for absolutely no reason whatsoever - just try again in this case if (await IsProfileUri(response.FinalUri, false).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningWorkaroundTriggered, nameof(IsProfileUri))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatWarningWorkaroundTriggered(nameof(IsProfileUri))); return await UnlockParentalAccountForService(service, parentalCode, --maxTries).ConfigureAwait(false); } diff --git a/ArchiSteamFarm/Steam/Integration/BotCredentialsProvider.cs b/ArchiSteamFarm/Steam/Integration/BotCredentialsProvider.cs index ec105243a..2cfd8844a 100644 --- a/ArchiSteamFarm/Steam/Integration/BotCredentialsProvider.cs +++ b/ArchiSteamFarm/Steam/Integration/BotCredentialsProvider.cs @@ -23,7 +23,6 @@ using System; using System.ComponentModel; -using System.Globalization; using System.Threading; using System.Threading.Tasks; using ArchiSteamFarm.Core; @@ -79,7 +78,7 @@ internal sealed class BotCredentialsProvider : IAuthenticator { if (previousCodeWasIncorrect && (++LoginFailures >= MaxLoginFailures)) { EResult reason = inputType == ASF.EUserInputType.TwoFactorAuthentication ? EResult.TwoFactorCodeMismatch : EResult.InvalidLoginAuthCode; - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.BotUnableToLogin, reason, reason)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatBotUnableToLogin(reason, reason)); await CancellationTokenSource.CancelAsync().ConfigureAwait(false); diff --git a/ArchiSteamFarm/Steam/Integration/Callbacks/UserNotificationsCallback.cs b/ArchiSteamFarm/Steam/Integration/Callbacks/UserNotificationsCallback.cs index e4e7ee05f..e62b094a6 100644 --- a/ArchiSteamFarm/Steam/Integration/Callbacks/UserNotificationsCallback.cs +++ b/ArchiSteamFarm/Steam/Integration/Callbacks/UserNotificationsCallback.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using ArchiSteamFarm.Core; using ArchiSteamFarm.Localization; using JetBrains.Annotations; @@ -65,7 +64,7 @@ public sealed class UserNotificationsCallback : CallbackMsg { case EUserNotification.Trading: break; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(type), type)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(type), type)); break; } diff --git a/ArchiSteamFarm/Steam/Integration/SteamSaleEvent.cs b/ArchiSteamFarm/Steam/Integration/SteamSaleEvent.cs index 4e61e8fe0..69ad69da8 100644 --- a/ArchiSteamFarm/Steam/Integration/SteamSaleEvent.cs +++ b/ArchiSteamFarm/Steam/Integration/SteamSaleEvent.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Immutable; -using System.Globalization; using System.Threading; using System.Threading.Tasks; using AngleSharp.Dom; @@ -66,12 +65,12 @@ internal sealed class SteamSaleEvent : IAsyncDisposable, IDisposable { ImmutableHashSet? queue = await Bot.ArchiWebHandler.GenerateNewDiscoveryQueue().ConfigureAwait(false); if ((queue == null) || (queue.Count == 0)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(queue))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(queue))); break; } - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ClearingDiscoveryQueue, i)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatClearingDiscoveryQueue(i)); // We could in theory do this in parallel, but who knows what would happen... foreach (uint queuedAppID in queue) { @@ -84,7 +83,7 @@ internal sealed class SteamSaleEvent : IAsyncDisposable, IDisposable { return; } - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.DoneClearingDiscoveryQueue, i)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatDoneClearingDiscoveryQueue(i)); } Bot.ArchiLogger.LogGenericTrace(Strings.Done); @@ -113,7 +112,7 @@ internal sealed class SteamSaleEvent : IAsyncDisposable, IDisposable { } if (Debugging.IsUserDebugging) { - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, text)); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatContent(text)); } // It'd make more sense to check against "Come back tomorrow", but it might not cover out-of-the-event queue diff --git a/ArchiSteamFarm/Steam/Integration/SteamUtilities.cs b/ArchiSteamFarm/Steam/Integration/SteamUtilities.cs index 117f67949..e2caf16bf 100644 --- a/ArchiSteamFarm/Steam/Integration/SteamUtilities.cs +++ b/ArchiSteamFarm/Steam/Integration/SteamUtilities.cs @@ -90,7 +90,7 @@ public static class SteamUtilities { int startIndex = errorText.LastIndexOf('('); if (startIndex < 0) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(errorText), errorText)); return null; } @@ -100,7 +100,7 @@ public static class SteamUtilities { int endIndex = errorText.IndexOf(')', startIndex + 1); if (endIndex < 0) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(errorText), errorText)); return null; } @@ -109,7 +109,7 @@ public static class SteamUtilities { } if (!byte.TryParse(errorCodeText, out byte errorCode)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(errorText), errorText)); return null; } @@ -117,7 +117,7 @@ public static class SteamUtilities { EResult result = (EResult) errorCode; if (!Enum.IsDefined(result)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(errorText), errorText)); return null; } diff --git a/ArchiSteamFarm/Steam/Interaction/Actions.cs b/ArchiSteamFarm/Steam/Interaction/Actions.cs index 419e4d794..3c6af7c28 100644 --- a/ArchiSteamFarm/Steam/Interaction/Actions.cs +++ b/ArchiSteamFarm/Steam/Interaction/Actions.cs @@ -25,7 +25,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -233,17 +232,17 @@ public sealed class Actions : IAsyncDisposable, IDisposable { // We've accepted *something*, if caller didn't specify the IDs, that's enough for us if ((acceptedCreatorIDs == null) || (acceptedCreatorIDs.Count == 0)) { - return (true, handledConfirmations.Values, string.Format(CultureInfo.CurrentCulture, Strings.BotHandledConfirmations, handledConfirmations.Count)); + return (true, handledConfirmations.Values, Strings.FormatBotHandledConfirmations(handledConfirmations.Count)); } // If they did, check if we've already found everything we were supposed to if ((handledConfirmations.Count >= acceptedCreatorIDs.Count) && acceptedCreatorIDs.All(handledConfirmations.ContainsKey)) { - return (true, handledConfirmations.Values, string.Format(CultureInfo.CurrentCulture, Strings.BotHandledConfirmations, handledConfirmations.Count)); + return (true, handledConfirmations.Values, Strings.FormatBotHandledConfirmations(handledConfirmations.Count)); } } // If we've reached this point, then it's a failure for waitIfNeeded, and success otherwise - return (!waitIfNeeded, handledConfirmations?.Values, !waitIfNeeded ? string.Format(CultureInfo.CurrentCulture, Strings.BotHandledConfirmations, handledConfirmations?.Count ?? 0) : string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries)); + return (!waitIfNeeded, handledConfirmations?.Values, !waitIfNeeded ? Strings.FormatBotHandledConfirmations(handledConfirmations?.Count ?? 0) : Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries)); } [PublicAPI] @@ -303,7 +302,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { await Bot.ArchiHandler.PlayGames(gameIDs, gameName).ConfigureAwait(false); - return (true, gameIDs.Count > 0 ? string.Format(CultureInfo.CurrentCulture, Strings.BotIdlingSelectedGames, nameof(gameIDs), string.Join(", ", gameIDs)) : Strings.Done); + return (true, gameIDs.Count > 0 ? Strings.FormatBotIdlingSelectedGames(nameof(gameIDs), string.Join(", ", gameIDs)) : Strings.Done); } [PublicAPI] @@ -432,16 +431,16 @@ public sealed class Actions : IAsyncDisposable, IDisposable { } catch (TimeoutException e) { Bot.ArchiLogger.LogGenericWarningException(e); - return (false, string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return (false, Strings.FormatWarningFailedWithError(e.Message)); } catch (Exception e) { Bot.ArchiLogger.LogGenericException(e); - return (false, string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, e.Message)); + return (false, Strings.FormatWarningFailedWithError(e.Message)); } } if (inventory.Count == 0) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(inventory))); + return (false, Strings.FormatErrorIsEmpty(nameof(inventory))); } return await SendInventory(inventory, targetSteamID, tradeToken, customMessage, itemsPerTrade).ConfigureAwait(false); @@ -550,7 +549,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { foreach (ulong giftCardID in giftCardIDs.Where(gid => !HandledGifts.Contains(gid))) { HandledGifts.Add(giftCardID); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotAcceptingGift, giftCardID)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatBotAcceptingGift(giftCardID)); await LimitGiftsRequestsAsync().ConfigureAwait(false); bool result = await Bot.ArchiWebHandler.AcceptDigitalGiftCard(giftCardID).ConfigureAwait(false); @@ -578,7 +577,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { foreach (ulong guestPassID in guestPassIDs.Where(guestPassID => !HandledGifts.Contains(guestPassID))) { HandledGifts.Add(guestPassID); - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotAcceptingGift, guestPassID)); + Bot.ArchiLogger.LogGenericInfo(Strings.FormatBotAcceptingGift(guestPassID)); await LimitGiftsRequestsAsync().ConfigureAwait(false); SteamApps.RedeemGuestPassResponseCallback? response = await Bot.ArchiHandler.RedeemGuestPass(guestPassID).ConfigureAwait(false); @@ -587,7 +586,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { if (response.Result == EResult.OK) { Bot.ArchiLogger.LogGenericInfo(Strings.Success); } else { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Result)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(response.Result)); } } else { Bot.ArchiLogger.LogGenericWarning(Strings.WarningFailed); diff --git a/ArchiSteamFarm/Steam/Interaction/Commands.cs b/ArchiSteamFarm/Steam/Interaction/Commands.cs index d2669a10d..dca4418a3 100644 --- a/ArchiSteamFarm/Steam/Interaction/Commands.cs +++ b/ArchiSteamFarm/Steam/Interaction/Commands.cs @@ -357,8 +357,8 @@ public sealed class Commands { if (!string.IsNullOrEmpty(pluginsResponse)) { if (!await Bot.SendMessage(steamID, pluginsResponse).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, pluginsResponse)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatContent(pluginsResponse)); } } @@ -381,12 +381,12 @@ public sealed class Commands { if (feedback && !responseTask.IsCompleted) { if (!await Bot.SendTypingMessage(steamID).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendTypingMessage))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendTypingMessage))); } while (!responseTask.IsCompleted && (await Task.WhenAny(responseTask, Task.Delay(SteamTypingStatusDelay)).ConfigureAwait(false) != responseTask)) { if (!await Bot.SendTypingMessage(steamID).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendTypingMessage))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendTypingMessage))); } } } @@ -402,8 +402,8 @@ public sealed class Commands { } if (!await Bot.SendMessage(steamID, response).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, response)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatContent(response)); } } @@ -425,8 +425,8 @@ public sealed class Commands { if (!string.IsNullOrEmpty(pluginsResponse)) { if (!await Bot.SendMessage(chatGroupID, chatID, pluginsResponse).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, pluginsResponse)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatContent(pluginsResponse)); } } @@ -451,12 +451,12 @@ public sealed class Commands { string pleaseWaitMessage = FormatBotResponse(Strings.PleaseWait); if (!await Bot.SendMessage(chatGroupID, chatID, pleaseWaitMessage).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); } while (!responseTask.IsCompleted && (await Task.WhenAny(responseTask, Task.Delay(SteamTypingStatusDelay)).ConfigureAwait(false) != responseTask)) { if (!await Bot.SendMessage(chatGroupID, chatID, pleaseWaitMessage).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); } } } @@ -472,8 +472,8 @@ public sealed class Commands { } if (!await Bot.SendMessage(chatGroupID, chatID, response).ConfigureAwait(false)) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(Bot.SendMessage))); - Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, response)); + Bot.ArchiLogger.LogGenericWarning(Strings.FormatWarningFailedWithError(nameof(Bot.SendMessage))); + Bot.ArchiLogger.LogGenericDebug(Strings.FormatContent(response)); } } @@ -523,7 +523,7 @@ public sealed class Commands { (bool success, string? token, string message) = await Bot.Actions.GenerateTwoFactorAuthenticationToken().ConfigureAwait(false); - return FormatBotResponse(success && !string.IsNullOrEmpty(token) ? string.Format(CultureInfo.CurrentCulture, Strings.BotAuthenticatorToken, token) : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success && !string.IsNullOrEmpty(token) ? Strings.FormatBotAuthenticatorToken(token) : Strings.FormatWarningFailedWithError(message)); } private static async Task Response2FA(EAccess access, string botNames, ulong steamID = 0) { @@ -536,7 +536,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.Response2FA(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -565,7 +565,7 @@ public sealed class Commands { (bool success, _, string message) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(confirm).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task Response2FAConfirm(EAccess access, string botNames, bool confirm, ulong steamID = 0) { @@ -578,7 +578,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.Response2FAConfirm(GetProxyAccess(bot, access, steamID), confirm))).ConfigureAwait(false); @@ -615,7 +615,7 @@ public sealed class Commands { if ((index > 0) && (entry.Length > index + 1)) { if (!uint.TryParse(entry[(index + 1)..], out gameID) || (gameID == 0)) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(gameID)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(gameID)))); continue; } @@ -624,7 +624,7 @@ public sealed class Commands { } else if (uint.TryParse(entry, out gameID) && (gameID > 0)) { type = "SUB"; } else { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(gameID)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(gameID)))); continue; } @@ -634,7 +634,7 @@ public sealed class Commands { HashSet? packageIDs = ASF.GlobalDatabase?.GetPackageIDs(gameID, Bot.OwnedPackageIDs.Keys, 1); if (packageIDs is { Count: > 0 }) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicense, $"app/{gameID}", $"{EResult.Fail}/{EPurchaseResultDetail.AlreadyPurchased}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotAddLicense($"app/{gameID}", $"{EResult.Fail}/{EPurchaseResultDetail.AlreadyPurchased}"))); break; } @@ -642,7 +642,7 @@ public sealed class Commands { (EResult result, IReadOnlyCollection? grantedApps, IReadOnlyCollection? grantedPackages) = await Bot.Actions.AddFreeLicenseApp(gameID).ConfigureAwait(false); if (((grantedApps == null) || (grantedApps.Count == 0)) && ((grantedPackages == null) || (grantedPackages.Count == 0))) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicense, $"app/{gameID}", result))); + response.AppendLine(FormatBotResponse(Strings.FormatBotAddLicense($"app/{gameID}", result))); break; } @@ -650,20 +650,20 @@ public sealed class Commands { grantedApps ??= []; grantedPackages ??= []; - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicenseWithItems, $"app/{gameID}", result, string.Join(", ", grantedApps.Select(static appID => $"app/{appID}").Union(grantedPackages.Select(static subID => $"sub/{subID}")))))); + response.AppendLine(FormatBotResponse(Strings.FormatBotAddLicenseWithItems($"app/{gameID}", result, string.Join(", ", grantedApps.Select(static appID => $"app/{appID}").Union(grantedPackages.Select(static subID => $"sub/{subID}")))))); break; } default: { if (Bot.OwnedPackageIDs.ContainsKey(gameID)) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicense, $"sub/{gameID}", $"{EResult.Fail}/{EPurchaseResultDetail.AlreadyPurchased}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotAddLicense($"sub/{gameID}", $"{EResult.Fail}/{EPurchaseResultDetail.AlreadyPurchased}"))); break; } (EResult result, EPurchaseResultDetail purchaseResult) = await Bot.Actions.AddFreeLicensePackage(gameID).ConfigureAwait(false); - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicense, $"sub/{gameID}", $"{result}/{purchaseResult}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotAddLicense($"sub/{gameID}", $"{result}/{purchaseResult}"))); break; } @@ -684,7 +684,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAddLicense(GetProxyAccess(bot, access, steamID), query))).ConfigureAwait(false); @@ -711,16 +711,16 @@ public sealed class Commands { } if (!uint.TryParse(targetAppID, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } if (!ulong.TryParse(targetContextID, out ulong contextID) || (contextID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(contextID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(contextID))); } (bool success, string message) = await Bot.Actions.SendInventory(appID, contextID).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseAdvancedLoot(EAccess access, string botNames, string appID, string contextID, ulong steamID = 0) { @@ -735,7 +735,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedLoot(GetProxyAccess(bot, access, steamID), appID, contextID))).ConfigureAwait(false); @@ -760,7 +760,7 @@ public sealed class Commands { string[] flags = options.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (flags.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(flags))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(flags))); } ERedeemFlags redeemFlags = ERedeemFlags.None; @@ -808,7 +808,7 @@ public sealed class Commands { break; default: - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, flag)); + return FormatBotResponse(Strings.FormatErrorIsInvalid(flag)); } } @@ -827,7 +827,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedRedeem(GetProxyAccess(bot, access, steamID), options, keys, steamID))).ConfigureAwait(false); @@ -860,7 +860,7 @@ public sealed class Commands { (bool success, string message) = await Bot.Actions.SendInventory(appID, contextID, targetBot.SteamID).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private async Task ResponseAdvancedTransfer(EAccess access, string targetAppID, string targetContextID, string botNameTo) { @@ -875,15 +875,15 @@ public sealed class Commands { Bot? targetBot = Bot.GetBot(botNameTo); if (targetBot == null) { - return access >= EAccess.Owner ? FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNameTo)) : null; + return access >= EAccess.Owner ? FormatBotResponse(Strings.FormatBotNotFound(botNameTo)) : null; } if (!uint.TryParse(targetAppID, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } if (!ulong.TryParse(targetContextID, out ulong contextID) || (contextID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(contextID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(contextID))); } return await ResponseAdvancedTransfer(access, appID, contextID, targetBot).ConfigureAwait(false); @@ -902,21 +902,21 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } if (!uint.TryParse(targetAppID, out uint appID) || (appID == 0)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } if (!ulong.TryParse(targetContextID, out ulong contextID) || (contextID == 0)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(contextID))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(contextID))); } Bot? targetBot = Bot.GetBot(botNameTo); if (targetBot == null) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNameTo)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNameTo)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedTransfer(GetProxyAccess(bot, access, steamID), appID, contextID, targetBot))).ConfigureAwait(false); @@ -937,7 +937,7 @@ public sealed class Commands { uint count = Bot.GamesToRedeemInBackgroundCount; - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotGamesToRedeemInBackgroundCount, count)); + return FormatBotResponse(Strings.FormatBotGamesToRedeemInBackgroundCount(count)); } private static async Task ResponseBackgroundGamesRedeemer(EAccess access, string botNames, ulong steamID = 0) { @@ -950,7 +950,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseBackgroundGamesRedeemer(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -973,12 +973,12 @@ public sealed class Commands { } if (!Enum.TryParse(cryptoMethodText, true, out ArchiCryptoHelper.ECryptoMethod cryptoMethod)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(cryptoMethod))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(cryptoMethod))); } string? encryptedString = Actions.Encrypt(cryptoMethod, stringToEncrypt); - return FormatStaticResponse(!string.IsNullOrEmpty(encryptedString) ? string.Format(CultureInfo.CurrentCulture, Strings.Result, encryptedString) : Strings.WarningFailed); + return FormatStaticResponse(!string.IsNullOrEmpty(encryptedString) ? Strings.FormatResult(encryptedString) : Strings.WarningFailed); } private static string? ResponseExit(EAccess access) { @@ -992,7 +992,7 @@ public sealed class Commands { (bool success, string message) = Actions.Exit(); - return FormatStaticResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatStaticResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private async Task ResponseFarm(EAccess access) { @@ -1027,7 +1027,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseFarm(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -1042,7 +1042,7 @@ public sealed class Commands { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } - return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.FarmingBlacklistAppIDs.Count == 0 ? string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotDatabase.FarmingBlacklistAppIDs)) : string.Join(", ", Bot.BotDatabase.FarmingBlacklistAppIDs)); + return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.FarmingBlacklistAppIDs.Count == 0 ? Strings.FormatErrorIsEmpty(nameof(Bot.BotDatabase.FarmingBlacklistAppIDs)) : string.Join(", ", Bot.BotDatabase.FarmingBlacklistAppIDs)); } private static async Task ResponseFarmingBlacklist(EAccess access, string botNames, ulong steamID = 0) { @@ -1055,7 +1055,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -1079,14 +1079,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1119,7 +1119,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklistAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1143,14 +1143,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1178,7 +1178,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklistRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1193,7 +1193,7 @@ public sealed class Commands { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } - return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.FarmingPriorityQueueAppIDs.Count == 0 ? string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotDatabase.FarmingPriorityQueueAppIDs)) : string.Join(", ", Bot.BotDatabase.FarmingPriorityQueueAppIDs)); + return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.FarmingPriorityQueueAppIDs.Count == 0 ? Strings.FormatErrorIsEmpty(nameof(Bot.BotDatabase.FarmingPriorityQueueAppIDs)) : string.Join(", ", Bot.BotDatabase.FarmingPriorityQueueAppIDs)); } private static async Task ResponseFarmingQueue(EAccess access, string botNames, ulong steamID = 0) { @@ -1206,7 +1206,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueue(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -1230,14 +1230,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1277,7 +1277,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueueAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1301,14 +1301,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1341,7 +1341,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueueRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1364,12 +1364,12 @@ public sealed class Commands { } if (!Enum.TryParse(hashingMethodText, true, out ArchiCryptoHelper.EHashingMethod hashingMethod)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(hashingMethod))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(hashingMethod))); } string hash = Actions.Hash(hashingMethod, stringToHash); - return FormatStaticResponse(!string.IsNullOrEmpty(hash) ? string.Format(CultureInfo.CurrentCulture, Strings.Result, hash) : Strings.WarningFailed); + return FormatStaticResponse(!string.IsNullOrEmpty(hash) ? Strings.FormatResult(hash) : Strings.WarningFailed); } private string? ResponseHelp(EAccess access) { @@ -1399,7 +1399,7 @@ public sealed class Commands { } if (!Enum.TryParse(propertyName, true, out ASF.EUserInputType inputType) || (inputType == ASF.EUserInputType.None) || !Enum.IsDefined(inputType)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(inputType))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(inputType))); } bool result = Bot.SetUserInput(inputType, inputValue); @@ -1419,7 +1419,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseInput(GetProxyAccess(bot, access, steamID), propertyName, inputValue)))).ConfigureAwait(false); @@ -1444,7 +1444,7 @@ public sealed class Commands { uint? level = await Bot.ArchiHandler.GetLevel().ConfigureAwait(false); - return FormatBotResponse(level.HasValue ? string.Format(CultureInfo.CurrentCulture, Strings.BotLevel, level.Value) : Strings.WarningFailed); + return FormatBotResponse(level.HasValue ? Strings.FormatBotLevel(level.Value) : Strings.WarningFailed); } private static async Task ResponseLevel(EAccess access, string botNames, ulong steamID = 0) { @@ -1457,7 +1457,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLevel(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -1481,12 +1481,12 @@ public sealed class Commands { } if (Bot.BotConfig.LootableTypes.Count == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotConfig.LootableTypes))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(Bot.BotConfig.LootableTypes))); } (bool success, string message) = await Bot.Actions.SendInventory(filterFunction: item => Bot.BotConfig.LootableTypes.Contains(item.Type)).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseLoot(EAccess access, string botNames, ulong steamID = 0) { @@ -1499,7 +1499,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLoot(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -1525,20 +1525,20 @@ public sealed class Commands { } if (Bot.BotConfig.LootableTypes.Count == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotConfig.LootableTypes))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(Bot.BotConfig.LootableTypes))); } string[] appIDTexts = realAppIDsText.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (appIDTexts.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(appIDTexts))); } HashSet realAppIDs = []; foreach (string appIDText in appIDTexts) { if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } realAppIDs.Add(appID); @@ -1546,7 +1546,7 @@ public sealed class Commands { (bool success, string message) = await Bot.Actions.SendInventory(filterFunction: item => Bot.BotConfig.LootableTypes.Contains(item.Type) && (exclude ^ realAppIDs.Contains(item.RealAppID))).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseLootByRealAppIDs(EAccess access, string botNames, string realAppIDsText, bool exclude, ulong steamID = 0) { @@ -1560,7 +1560,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLootByRealAppIDs(GetProxyAccess(bot, access, steamID), realAppIDsText, exclude))).ConfigureAwait(false); @@ -1575,7 +1575,7 @@ public sealed class Commands { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } - return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.MatchActivelyBlacklistAppIDs.Count == 0 ? string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotDatabase.MatchActivelyBlacklistAppIDs)) : string.Join(", ", Bot.BotDatabase.MatchActivelyBlacklistAppIDs)); + return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.MatchActivelyBlacklistAppIDs.Count == 0 ? Strings.FormatErrorIsEmpty(nameof(Bot.BotDatabase.MatchActivelyBlacklistAppIDs)) : string.Join(", ", Bot.BotDatabase.MatchActivelyBlacklistAppIDs)); } private static async Task ResponseMatchActivelyBlacklist(EAccess access, string botNames, ulong steamID = 0) { @@ -1588,7 +1588,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -1612,14 +1612,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1639,7 +1639,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklistAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1663,14 +1663,14 @@ public sealed class Commands { string[] targets = targetAppIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet appIDs = []; foreach (string target in targets) { if (!uint.TryParse(target, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID))); } appIDs.Add(appID); @@ -1690,7 +1690,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklistRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false); @@ -1734,7 +1734,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseNickname(GetProxyAccess(bot, access, steamID), nickname)))).ConfigureAwait(false); @@ -1790,17 +1790,17 @@ public sealed class Commands { if (packageIDs?.Count > 0) { if ((gamesOwned != null) && gamesOwned.TryGetValue(appID, out string? cachedGameName)) { result[$"app/{appID}"] = cachedGameName; - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlreadyWithName, $"app/{appID}", cachedGameName))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlreadyWithName($"app/{appID}", cachedGameName))); } else { result[$"app/{appID}"] = appID.ToString(CultureInfo.InvariantCulture); - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlready, $"app/{appID}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlready($"app/{appID}"))); } } else { if (gamesOwned == null) { gamesOwned = await FetchGamesOwned().ConfigureAwait(false); if (gamesOwned == null) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(gamesOwned)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(gamesOwned)))); break; } @@ -1808,9 +1808,9 @@ public sealed class Commands { if (gamesOwned.TryGetValue(appID, out string? gameName)) { result[$"app/{appID}"] = gameName; - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlreadyWithName, $"app/{appID}", gameName))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlreadyWithName($"app/{appID}", gameName))); } else { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotOwnedYet, $"app/{appID}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotNotOwnedYet($"app/{appID}"))); } } @@ -1822,7 +1822,7 @@ public sealed class Commands { regex = new Regex(game, RegexOptions.CultureInvariant); } catch (ArgumentException e) { Bot.ArchiLogger.LogGenericWarningException(e); - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(regex)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(regex)))); break; } @@ -1831,7 +1831,7 @@ public sealed class Commands { gamesOwned = await FetchGamesOwned().ConfigureAwait(false); if (gamesOwned == null) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(gamesOwned)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(gamesOwned)))); break; } @@ -1843,20 +1843,20 @@ public sealed class Commands { foundWithRegex = true; result[$"app/{appID}"] = gameName; - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlreadyWithName, $"app/{appID}", gameName))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlreadyWithName($"app/{appID}", gameName))); } if (!foundWithRegex) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotOwnedYet, entry))); + response.AppendLine(FormatBotResponse(Strings.FormatBotNotOwnedYet(entry))); } continue; case "S" or "SUB" when uint.TryParse(game, out uint packageID) && (packageID > 0): if (Bot.OwnedPackageIDs.ContainsKey(packageID)) { result[$"sub/{packageID}"] = packageID.ToString(CultureInfo.InvariantCulture); - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlready, $"sub/{packageID}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlready($"sub/{packageID}"))); } else { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotOwnedYet, $"sub/{packageID}"))); + response.AppendLine(FormatBotResponse(Strings.FormatBotNotOwnedYet($"sub/{packageID}"))); } break; @@ -1865,7 +1865,7 @@ public sealed class Commands { gamesOwned = await FetchGamesOwned().ConfigureAwait(false); if (gamesOwned == null) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(gamesOwned)))); + response.AppendLine(FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(gamesOwned)))); break; } @@ -1877,18 +1877,18 @@ public sealed class Commands { foundWithName = true; result[$"app/{appID}"] = gameName; - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnedAlreadyWithName, $"app/{appID}", gameName))); + response.AppendLine(FormatBotResponse(Strings.FormatBotOwnedAlreadyWithName($"app/{appID}", gameName))); } if (!foundWithName) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotOwnedYet, entry))); + response.AppendLine(FormatBotResponse(Strings.FormatBotNotOwnedYet(entry))); } break; } } - return (response.Length > 0 ? response.ToString() : FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotOwnedYet, query)), result); + return (response.Length > 0 ? response.ToString() : FormatBotResponse(Strings.FormatBotNotOwnedYet(query)), result); } private static async Task ResponseOwns(EAccess access, string botNames, string query, ulong steamID = 0) { @@ -1902,7 +1902,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList<(string? Response, Dictionary? OwnedGames)> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseOwns(GetProxyAccess(bot, access, steamID), query))).ConfigureAwait(false); @@ -1927,7 +1927,7 @@ public sealed class Commands { ownedGamesStats[gameID] = ownedGameStats; } - IEnumerable extraResponses = ownedGamesStats.Select(kv => FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotOwnsOverviewPerGame, kv.Value.Count, validResults.Count, $"{kv.Key}{(!string.IsNullOrEmpty(kv.Value.GameName) ? $" | {kv.Value.GameName}" : "")}"))); + IEnumerable extraResponses = ownedGamesStats.Select(kv => FormatStaticResponse(Strings.FormatBotOwnsOverviewPerGame(kv.Value.Count, validResults.Count, $"{kv.Key}{(!string.IsNullOrEmpty(kv.Value.GameName) ? $" | {kv.Value.GameName}" : "")}"))); return string.Join(Environment.NewLine, validResults.Select(static result => result.Response).Concat(extraResponses)); } @@ -1948,12 +1948,12 @@ public sealed class Commands { ushort resumeInSeconds = 0; if (!string.IsNullOrEmpty(resumeInSecondsText) && (!ushort.TryParse(resumeInSecondsText, out resumeInSeconds) || (resumeInSeconds == 0))) { - return string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(resumeInSecondsText)); + return Strings.FormatErrorIsInvalid(nameof(resumeInSecondsText)); } (bool success, string message) = await Bot.Actions.Pause(permanent, resumeInSeconds).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponsePause(EAccess access, string botNames, bool permanent, string? resumeInSecondsText = null, ulong steamID = 0) { @@ -1966,7 +1966,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePause(GetProxyAccess(bot, access, steamID), permanent, resumeInSecondsText))).ConfigureAwait(false); @@ -1997,7 +1997,7 @@ public sealed class Commands { (bool success, string message) = await Bot.Actions.Play(gameIDs, gameName).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private async Task ResponsePlay(EAccess access, string targetGameIDs) { @@ -2018,7 +2018,7 @@ public sealed class Commands { string[] games = targetGameIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (games.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(games))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(games))); } HashSet gamesToPlay = new(Math.Min(games.Length, ArchiHandler.MaxGamesPlayedConcurrently)); @@ -2036,7 +2036,7 @@ public sealed class Commands { } if (gamesToPlay.Count >= ArchiHandler.MaxGamesPlayedConcurrently) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(gamesToPlay)} > {ArchiHandler.MaxGamesPlayedConcurrently}")); + return FormatBotResponse(Strings.FormatWarningFailedWithError($"{nameof(gamesToPlay)} > {ArchiHandler.MaxGamesPlayedConcurrently}")); } gamesToPlay.Add(gameID); @@ -2056,7 +2056,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePlay(GetProxyAccess(bot, access, steamID), targetGameIDs))).ConfigureAwait(false); @@ -2081,7 +2081,7 @@ public sealed class Commands { uint? points = await Bot.ArchiWebHandler.GetPointsBalance().ConfigureAwait(false); - return FormatBotResponse(points.HasValue ? string.Format(CultureInfo.CurrentCulture, Strings.BotPointsBalance, points) : Strings.WarningFailed); + return FormatBotResponse(points.HasValue ? Strings.FormatBotPointsBalance(points) : Strings.WarningFailed); } private static async Task ResponsePointsBalance(EAccess access, string botNames, ulong steamID = 0) { @@ -2094,7 +2094,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePointsBalance(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -2126,9 +2126,9 @@ public sealed class Commands { switch (privacySettingsArgs.Length) { case 0: - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(privacySettingsArgs))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(privacySettingsArgs))); case > privacySettings: - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(privacySettingsArgs))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(privacySettingsArgs))); } ArchiHandler.EPrivacySetting profile = ArchiHandler.EPrivacySetting.Private; @@ -2142,7 +2142,7 @@ public sealed class Commands { // Converting digits to enum for (byte index = 0; index < privacySettingsArgs.Length; index++) { if (!Enum.TryParse(privacySettingsArgs[index], true, out ArchiHandler.EPrivacySetting privacySetting) || (privacySetting == ArchiHandler.EPrivacySetting.Unknown) || !Enum.IsDefined(privacySetting)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(privacySettingsArgs))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(privacySettingsArgs))); } // Child setting can't be less restrictive than its parent @@ -2155,7 +2155,7 @@ public sealed class Commands { case 1: // OwnedGames, child of Profile if (profile < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(ownedGames))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(ownedGames))); } ownedGames = privacySetting; @@ -2164,7 +2164,7 @@ public sealed class Commands { case 2: // Playtime, child of OwnedGames if (ownedGames < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(playtime))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(playtime))); } playtime = privacySetting; @@ -2173,7 +2173,7 @@ public sealed class Commands { case 3: // FriendsList, child of Profile if (profile < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(ownedGames))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(ownedGames))); } friendsList = privacySetting; @@ -2182,7 +2182,7 @@ public sealed class Commands { case 4: // Inventory, child of Profile if (profile < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(inventory))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(inventory))); } inventory = privacySetting; @@ -2191,7 +2191,7 @@ public sealed class Commands { case 5: // InventoryGifts, child of Inventory if (inventory < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(inventoryGifts))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(inventoryGifts))); } inventoryGifts = privacySetting; @@ -2200,7 +2200,7 @@ public sealed class Commands { case 6: // Comments, child of Profile if (profile < privacySetting) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(comments))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(comments))); } // Comments use different numbers than everything else, but we want to have this command consistent for end-user, so we'll map them @@ -2218,16 +2218,16 @@ public sealed class Commands { break; default: - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(privacySetting), privacySetting)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(privacySetting), privacySetting)); - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(privacySetting))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(privacySetting))); } break; default: - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(index), index)); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(index), index)); - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(index))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(index))); } } @@ -2247,7 +2247,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePrivacy(GetProxyAccess(bot, access, steamID), privacySettingsText))).ConfigureAwait(false); @@ -2283,7 +2283,7 @@ public sealed class Commands { string[] keys = keysText.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (keys.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(keys))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(keys))); } bool forward = !redeemFlags.HasFlag(ERedeemFlags.SkipForwarding) && (redeemFlags.HasFlag(ERedeemFlags.ForceForwarding) || Bot.BotConfig.RedeemingPreferences.HasFlag(BotConfig.ERedeemingPreferences.Forwarding)); @@ -2351,7 +2351,7 @@ public sealed class Commands { } if ((result == EResult.Timeout) || (purchaseResultDetail == EPurchaseResultDetail.Timeout)) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotRedeem, key, $"{result}/{purchaseResultDetail}"), currentBot.BotName)); + response.AppendLine(FormatBotResponse(Strings.FormatBotRedeem(key, $"{result}/{purchaseResultDetail}"), currentBot.BotName)); // Either bot will be changed, or loop aborted currentBot = null; @@ -2375,9 +2375,9 @@ public sealed class Commands { } if (items?.Count > 0) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotRedeemWithItems, key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}", string.Join(", ", items)), currentBot.BotName)); + response.AppendLine(FormatBotResponse(Strings.FormatBotRedeemWithItems(key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}", string.Join(", ", items)), currentBot.BotName)); } else if (!skipRequest) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotRedeem, key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}"), currentBot.BotName)); + response.AppendLine(FormatBotResponse(Strings.FormatBotRedeem(key, $"{result}/{purchaseResultDetail}{(!string.IsNullOrEmpty(balanceText) ? $"/{balanceText}" : "")}"), currentBot.BotName)); } switch (purchaseResultDetail) { @@ -2427,7 +2427,7 @@ public sealed class Commands { CStore_RegisterCDKey_Response? redeemResponse = await innerBot.Actions.RedeemKey(key).ConfigureAwait(false); if (redeemResponse == null) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotRedeem, key, $"{EResult.Timeout}/{EPurchaseResultDetail.Timeout}"), innerBot.BotName)); + response.AppendLine(FormatBotResponse(Strings.FormatBotRedeem(key, $"{EResult.Timeout}/{EPurchaseResultDetail.Timeout}"), innerBot.BotName)); continue; } @@ -2455,7 +2455,7 @@ public sealed class Commands { Dictionary? redeemItems = redeemResponse.purchase_receipt_info.line_items.Count > 0 ? redeemResponse.purchase_receipt_info.line_items.ToDictionary(static lineItem => lineItem.packageid, static lineItem => lineItem.line_item_description) : null; - response.AppendLine(FormatBotResponse(redeemItems?.Count > 0 ? string.Format(CultureInfo.CurrentCulture, Strings.BotRedeemWithItems, key, $"{redeemResult}/{redeemPurchaseResult}", string.Join(", ", redeemItems)) : string.Format(CultureInfo.CurrentCulture, Strings.BotRedeem, key, $"{redeemResult}/{redeemPurchaseResult}"), innerBot.BotName)); + response.AppendLine(FormatBotResponse(redeemItems?.Count > 0 ? Strings.FormatBotRedeemWithItems(key, $"{redeemResult}/{redeemPurchaseResult}", string.Join(", ", redeemItems)) : Strings.FormatBotRedeem(key, $"{redeemResult}/{redeemPurchaseResult}"), innerBot.BotName)); if (alreadyHandled) { break; @@ -2480,7 +2480,7 @@ public sealed class Commands { goto case EPurchaseResultDetail.CancelledByUser; default: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(purchaseResultDetail), purchaseResultDetail)); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(purchaseResultDetail), purchaseResultDetail)); unusedKeys.Remove(key); @@ -2510,7 +2510,7 @@ public sealed class Commands { } if (unusedKeys.Count > 0) { - response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.UnusedKeys, string.Join(", ", unusedKeys)))); + response.AppendLine(FormatBotResponse(Strings.FormatUnusedKeys(string.Join(", ", unusedKeys)))); } return response.Length > 0 ? response.ToString() : null; @@ -2527,7 +2527,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseRedeem(GetProxyAccess(bot, access, steamID), keysText, steamID, redeemFlags))).ConfigureAwait(false); @@ -2565,7 +2565,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseReset(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -2586,7 +2586,7 @@ public sealed class Commands { (bool success, string message) = Actions.Restart(); - return FormatStaticResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatStaticResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private string? ResponseResume(EAccess access) { @@ -2600,7 +2600,7 @@ public sealed class Commands { (bool success, string message) = Bot.Actions.Resume(); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseResume(EAccess access, string botNames, ulong steamID = 0) { @@ -2613,7 +2613,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseResume(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -2634,7 +2634,7 @@ public sealed class Commands { (bool success, string message) = Bot.Actions.Start(); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseStart(EAccess access, string botNames, ulong steamID = 0) { @@ -2647,7 +2647,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStart(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -2669,7 +2669,7 @@ public sealed class Commands { ushort memoryInMegabytes = (ushort) (GC.GetTotalMemory(false) / 1024 / 1024); TimeSpan uptime = DateTime.UtcNow.Subtract(OS.ProcessStartTime); - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotStats, memoryInMegabytes, uptime.ToHumanReadable())); + return FormatBotResponse(Strings.FormatBotStats(memoryInMegabytes, uptime.ToHumanReadable())); } private (string? Response, Bot Bot) ResponseStatus(EAccess access) { @@ -2706,12 +2706,12 @@ public sealed class Commands { } if (Bot.CardsFarmer.CurrentGamesFarmingReadOnly.Count > 1) { - return (FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotStatusIdlingList, string.Join(", ", Bot.CardsFarmer.CurrentGamesFarmingReadOnly.Select(static game => $"{game.AppID} ({game.GameName})")), Bot.CardsFarmer.GamesToFarmReadOnly.Count, Bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining), Bot.CardsFarmer.TimeRemaining.ToHumanReadable())), Bot); + return (FormatBotResponse(Strings.FormatBotStatusIdlingList(string.Join(", ", Bot.CardsFarmer.CurrentGamesFarmingReadOnly.Select(static game => $"{game.AppID} ({game.GameName})")), Bot.CardsFarmer.GamesToFarmReadOnly.Count, Bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining), Bot.CardsFarmer.TimeRemaining.ToHumanReadable())), Bot); } Game soloGame = Bot.CardsFarmer.CurrentGamesFarmingReadOnly.First(); - return (FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotStatusIdling, soloGame.AppID, soloGame.GameName, soloGame.CardsRemaining, Bot.CardsFarmer.GamesToFarmReadOnly.Count, Bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining), Bot.CardsFarmer.TimeRemaining.ToHumanReadable())), Bot); + return (FormatBotResponse(Strings.FormatBotStatusIdling(soloGame.AppID, soloGame.GameName, soloGame.CardsRemaining, Bot.CardsFarmer.GamesToFarmReadOnly.Count, Bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining), Bot.CardsFarmer.TimeRemaining.ToHumanReadable())), Bot); } private static async Task ResponseStatus(EAccess access, string botNames, ulong steamID = 0) { @@ -2724,7 +2724,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList<(string? Response, Bot Bot)> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStatus(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -2737,7 +2737,7 @@ public sealed class Commands { HashSet botsRunning = validResults.Where(static result => result.Bot.KeepRunning).Select(static result => result.Bot).ToHashSet(); - string extraResponse = string.Format(CultureInfo.CurrentCulture, Strings.BotStatusOverview, botsRunning.Count, validResults.Count, botsRunning.Sum(static bot => bot.CardsFarmer.GamesToFarmReadOnly.Count), botsRunning.Sum(static bot => bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining))); + string extraResponse = Strings.FormatBotStatusOverview(botsRunning.Count, validResults.Count, botsRunning.Sum(static bot => bot.CardsFarmer.GamesToFarmReadOnly.Count), botsRunning.Sum(static bot => bot.CardsFarmer.GamesToFarmReadOnly.Sum(static game => game.CardsRemaining))); return string.Join(Environment.NewLine, validResults.Select(static result => result.Response).Union(extraResponse.ToEnumerable())); } @@ -2753,7 +2753,7 @@ public sealed class Commands { (bool success, string message) = Bot.Actions.Stop(); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseStop(EAccess access, string botNames, ulong steamID = 0) { @@ -2766,7 +2766,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStop(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -2781,7 +2781,7 @@ public sealed class Commands { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } - return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.TradingBlacklistSteamIDs.Count == 0 ? string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotDatabase.TradingBlacklistSteamIDs)) : string.Join(", ", Bot.BotDatabase.TradingBlacklistSteamIDs)); + return access < EAccess.Master ? null : FormatBotResponse(Bot.BotDatabase.TradingBlacklistSteamIDs.Count == 0 ? Strings.FormatErrorIsEmpty(nameof(Bot.BotDatabase.TradingBlacklistSteamIDs)) : string.Join(", ", Bot.BotDatabase.TradingBlacklistSteamIDs)); } private static async Task ResponseTradingBlacklist(EAccess access, string botNames, ulong steamID = 0) { @@ -2794,7 +2794,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); @@ -2818,14 +2818,14 @@ public sealed class Commands { string[] targets = targetSteamIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet targetIDs = []; foreach (string target in targets) { if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(targetID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(targetID))); } targetIDs.Add(targetID); @@ -2845,7 +2845,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklistAdd(GetProxyAccess(bot, access, steamID), targetSteamIDs)))).ConfigureAwait(false); @@ -2869,14 +2869,14 @@ public sealed class Commands { string[] targets = targetSteamIDs.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (targets.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(targets))); } HashSet targetIDs = []; foreach (string target in targets) { if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(targetID))); + return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(targetID))); } targetIDs.Add(targetID); @@ -2896,7 +2896,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklistRemove(GetProxyAccess(bot, access, steamID), targetSteamIDs)))).ConfigureAwait(false); @@ -2922,13 +2922,13 @@ public sealed class Commands { } if (Bot.BotConfig.TransferableTypes.Count == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotConfig.TransferableTypes))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(Bot.BotConfig.TransferableTypes))); } Bot? targetBot = Bot.GetBot(botNameTo); if (targetBot == null) { - return access >= EAccess.Owner ? FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNameTo)) : null; + return access >= EAccess.Owner ? FormatBotResponse(Strings.FormatBotNotFound(botNameTo)) : null; } if (!targetBot.IsConnectedAndLoggedOn) { @@ -2941,7 +2941,7 @@ public sealed class Commands { (bool success, string message) = await Bot.Actions.SendInventory(targetSteamID: targetBot.SteamID, filterFunction: item => Bot.BotConfig.TransferableTypes.Contains(item.Type)).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private static async Task ResponseTransfer(EAccess access, string botNames, string botNameTo, ulong steamID = 0) { @@ -2955,7 +2955,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseTransfer(GetProxyAccess(bot, access, steamID), botNameTo))).ConfigureAwait(false); @@ -2985,7 +2985,7 @@ public sealed class Commands { } if (Bot.BotConfig.TransferableTypes.Count == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(Bot.BotConfig.TransferableTypes))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(Bot.BotConfig.TransferableTypes))); } if (!targetBot.IsConnectedAndLoggedOn) { @@ -2998,7 +2998,7 @@ public sealed class Commands { (bool success, string message) = await Bot.Actions.SendInventory(targetSteamID: targetBot.SteamID, filterFunction: item => Bot.BotConfig.TransferableTypes.Contains(item.Type) && (exclude ^ realAppIDs.Contains(item.RealAppID))).ConfigureAwait(false); - return FormatBotResponse(success ? message : string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, message)); + return FormatBotResponse(success ? message : Strings.FormatWarningFailedWithError(message)); } private async Task ResponseTransferByRealAppIDs(EAccess access, string realAppIDsText, string botNameTo, bool exclude) { @@ -3016,20 +3016,20 @@ public sealed class Commands { Bot? targetBot = Bot.GetBot(botNameTo); if (targetBot == null) { - return access >= EAccess.Owner ? FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNameTo)) : null; + return access >= EAccess.Owner ? FormatBotResponse(Strings.FormatBotNotFound(botNameTo)) : null; } string[] appIDTexts = realAppIDsText.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (appIDTexts.Length == 0) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts))); + return FormatBotResponse(Strings.FormatErrorIsEmpty(nameof(appIDTexts))); } HashSet realAppIDs = []; foreach (string appIDText in appIDTexts) { if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) { - return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatBotResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } realAppIDs.Add(appID); @@ -3050,20 +3050,20 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } string[] appIDTexts = realAppIDsText.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (appIDTexts.Length == 0) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts))); + return FormatStaticResponse(Strings.FormatErrorIsEmpty(nameof(appIDTexts))); } HashSet realAppIDs = []; foreach (string appIDText in appIDTexts) { if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(appID))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(appID))); } realAppIDs.Add(appID); @@ -3072,7 +3072,7 @@ public sealed class Commands { Bot? targetBot = Bot.GetBot(botNameTo); if (targetBot == null) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNameTo)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNameTo)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseTransferByRealAppIDs(GetProxyAccess(bot, access, steamID), realAppIDs, targetBot, exclude))).ConfigureAwait(false); @@ -3136,7 +3136,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseUnpackBoosters(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false); @@ -3165,7 +3165,7 @@ public sealed class Commands { } if (!Enum.TryParse(channelText, true, out channel) || (channel == GlobalConfig.EUpdateChannel.None)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(channelText))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(channelText))); } } @@ -3193,7 +3193,7 @@ public sealed class Commands { } if (!Enum.TryParse(channelText, true, out GlobalConfig.EUpdateChannel parsedChannel) || (parsedChannel == GlobalConfig.EUpdateChannel.None)) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(channelText))); + return FormatStaticResponse(Strings.FormatErrorIsInvalid(nameof(channelText))); } channel = parsedChannel; @@ -3206,7 +3206,7 @@ public sealed class Commands { string[] plugins = pluginsText.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries); if (plugins.Length == 0) { - return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(plugins))); + return FormatStaticResponse(Strings.FormatErrorIsEmpty(nameof(plugins))); } (success, message) = await Actions.UpdatePlugins(channel, plugins, forced).ConfigureAwait(false); @@ -3222,7 +3222,7 @@ public sealed class Commands { throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess)); } - return access >= EAccess.FamilySharing ? FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotVersion, SharedInfo.ASF, SharedInfo.Version)) : null; + return access >= EAccess.FamilySharing ? FormatBotResponse(Strings.FormatBotVersion(SharedInfo.ASF, SharedInfo.Version)) : null; } private string? ResponseWalletBalance(EAccess access) { @@ -3234,7 +3234,7 @@ public sealed class Commands { return null; } - return !Bot.IsConnectedAndLoggedOn ? FormatBotResponse(Strings.BotNotConnected) : FormatBotResponse(Bot.WalletCurrency != ECurrencyCode.Invalid ? string.Format(CultureInfo.CurrentCulture, Strings.BotWalletBalance, $"{Bot.WalletBalance / 100.0}{(Bot.WalletBalanceDelayed > 0 ? $" ({(Bot.WalletBalance + Bot.WalletBalanceDelayed) / 100.0})" : "")}", Bot.WalletCurrency.ToString()) : Strings.BotHasNoWallet); + return !Bot.IsConnectedAndLoggedOn ? FormatBotResponse(Strings.BotNotConnected) : FormatBotResponse(Bot.WalletCurrency != ECurrencyCode.Invalid ? Strings.FormatBotWalletBalance($"{Bot.WalletBalance / 100.0}{(Bot.WalletBalanceDelayed > 0 ? $" ({(Bot.WalletBalance + Bot.WalletBalanceDelayed) / 100.0})" : "")}", Bot.WalletCurrency.ToString()) : Strings.BotHasNoWallet); } private static async Task ResponseWalletBalance(EAccess access, string botNames, ulong steamID = 0) { @@ -3247,7 +3247,7 @@ public sealed class Commands { HashSet? bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { - return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null; + return access >= EAccess.Owner ? FormatStaticResponse(Strings.FormatBotNotFound(botNames)) : null; } IList results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseWalletBalance(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false); diff --git a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs index efc20b3ce..b87e3d523 100644 --- a/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs +++ b/ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs @@ -25,7 +25,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Linq; using System.Security.Cryptography; using System.Text; @@ -107,7 +106,7 @@ public sealed class MobileAuthenticator : IDisposable { sharedSecret = Convert.FromBase64String(SharedSecret); } catch (FormatException e) { Bot.ArchiLogger.LogGenericException(e); - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(SharedSecret))); + Bot.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(SharedSecret))); return null; } @@ -155,7 +154,7 @@ public sealed class MobileAuthenticator : IDisposable { (_, string? deviceID) = await CachedDeviceID.GetValue(ECacheFallback.SuccessPreviously).ConfigureAwait(false); if (string.IsNullOrEmpty(deviceID)) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(deviceID))); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(nameof(deviceID))); return null; } @@ -183,7 +182,7 @@ public sealed class MobileAuthenticator : IDisposable { } foreach (Confirmation? confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(confirmation.ConfirmationType))) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(confirmation.ConfirmationType), $"{confirmation.ConfirmationType} ({confirmation.ConfirmationTypeName ?? "null"})")); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(confirmation.ConfirmationType), $"{confirmation.ConfirmationType} ({confirmation.ConfirmationTypeName ?? "null"})")); } return response.Confirmations; @@ -239,7 +238,7 @@ public sealed class MobileAuthenticator : IDisposable { (_, string? deviceID) = await CachedDeviceID.GetValue(ECacheFallback.SuccessPreviously).ConfigureAwait(false); if (string.IsNullOrEmpty(deviceID)) { - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(deviceID))); + Bot.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(nameof(deviceID))); return false; } @@ -331,7 +330,7 @@ public sealed class MobileAuthenticator : IDisposable { identitySecret = Convert.FromBase64String(IdentitySecret); } catch (FormatException e) { Bot.ArchiLogger.LogGenericException(e); - Bot.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(IdentitySecret))); + Bot.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(IdentitySecret))); return null; } diff --git a/ArchiSteamFarm/Steam/Storage/BotConfig.cs b/ArchiSteamFarm/Steam/Storage/BotConfig.cs index 8f5a90eea..299f548b6 100644 --- a/ArchiSteamFarm/Steam/Storage/BotConfig.cs +++ b/ArchiSteamFarm/Steam/Storage/BotConfig.cs @@ -401,7 +401,7 @@ public sealed class BotConfig { internal (bool Valid, string? ErrorMessage) CheckValidation() { if (BotBehaviour > EBotBehaviour.All) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(BotBehaviour), BotBehaviour)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(BotBehaviour), BotBehaviour)); } if (!string.IsNullOrEmpty(CustomGamePlayedWhileFarming)) { @@ -409,31 +409,31 @@ public sealed class BotConfig { // Test CustomGamePlayedWhileFarming against supported format, otherwise we'll throw later when used string _ = string.Format(CultureInfo.CurrentCulture, CustomGamePlayedWhileFarming, null, null); } catch (FormatException e) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(CustomGamePlayedWhileFarming), e.Message)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(CustomGamePlayedWhileFarming), e.Message)); } } foreach (EFarmingOrder farmingOrder in FarmingOrders.Where(static farmingOrder => !Enum.IsDefined(farmingOrder))) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(FarmingOrders), farmingOrder)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(FarmingOrders), farmingOrder)); } if (GamesPlayedWhileIdle.Contains(0)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(GamesPlayedWhileIdle), 0)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(GamesPlayedWhileIdle), 0)); } if (GamesPlayedWhileIdle.Count > ArchiHandler.MaxGamesPlayedConcurrently) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(GamesPlayedWhileIdle), $"{nameof(GamesPlayedWhileIdle.Count)} {GamesPlayedWhileIdle.Count} > {ArchiHandler.MaxGamesPlayedConcurrently}")); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(GamesPlayedWhileIdle), $"{nameof(GamesPlayedWhileIdle.Count)} {GamesPlayedWhileIdle.Count} > {ArchiHandler.MaxGamesPlayedConcurrently}")); } foreach (EAssetType lootableType in LootableTypes.Where(static lootableType => !Enum.IsDefined(lootableType))) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(LootableTypes), lootableType)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(LootableTypes), lootableType)); } HashSet? completeTypesToSendValidTypes = null; foreach (EAssetType completableType in CompleteTypesToSend) { if (!Enum.IsDefined(completableType)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(CompleteTypesToSend), completableType)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(CompleteTypesToSend), completableType)); } if (completeTypesToSendValidTypes == null) { @@ -447,57 +447,57 @@ public sealed class BotConfig { } if (!completeTypesToSendValidTypes.Contains(completableType)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(CompleteTypesToSend), completableType)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(CompleteTypesToSend), completableType)); } } foreach (EAssetType matchableType in MatchableTypes.Where(static matchableType => !Enum.IsDefined(matchableType))) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(MatchableTypes), matchableType)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(MatchableTypes), matchableType)); } if (OnlineFlags < 0) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(OnlineFlags), OnlineFlags)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OnlineFlags), OnlineFlags)); } if (!Enum.IsDefined(OnlineStatus)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(OnlineStatus), OnlineStatus)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OnlineStatus), OnlineStatus)); } if (!Enum.IsDefined(PasswordFormat)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(PasswordFormat), PasswordFormat)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(PasswordFormat), PasswordFormat)); } if (RedeemingPreferences > ERedeemingPreferences.All) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(RedeemingPreferences), RedeemingPreferences)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(RedeemingPreferences), RedeemingPreferences)); } if ((SteamMasterClanID != 0) && !new SteamID(SteamMasterClanID).IsClanAccount) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamMasterClanID), SteamMasterClanID)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamMasterClanID), SteamMasterClanID)); } if (!string.IsNullOrEmpty(SteamParentalCode) && ((SteamParentalCode.Length != SteamParentalCodeLength) || SteamParentalCode.Any(static character => character is < '0' or > '9'))) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamParentalCode), SteamParentalCode)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamParentalCode), SteamParentalCode)); } if (!string.IsNullOrEmpty(SteamTradeToken) && (SteamTradeToken.Length != SteamTradeTokenLength)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamTradeToken), SteamTradeToken)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamTradeToken), SteamTradeToken)); } foreach ((ulong steamID, EAccess permission) in SteamUserPermissions) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamUserPermissions), steamID)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamUserPermissions), steamID)); } if (!Enum.IsDefined(permission)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamUserPermissions), permission)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamUserPermissions), permission)); } } if (TradingPreferences > ETradingPreferences.All) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(TradingPreferences), TradingPreferences)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(TradingPreferences), TradingPreferences)); } - return !Enum.IsDefined(UserInterfaceMode) ? (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UserInterfaceMode), UserInterfaceMode)) : (true, null); + return !Enum.IsDefined(UserInterfaceMode) ? (false, Strings.FormatErrorConfigPropertyInvalid(nameof(UserInterfaceMode), UserInterfaceMode)) : (true, null); } internal async Task GetDecryptedSteamPassword() { @@ -513,7 +513,7 @@ public sealed class BotConfig { string? result = await ArchiCryptoHelper.Decrypt(PasswordFormat, SteamPassword).ConfigureAwait(false); if (string.IsNullOrEmpty(result)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(SteamPassword))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsInvalid(nameof(SteamPassword))); return null; } @@ -535,7 +535,7 @@ public sealed class BotConfig { json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return (null, null); } @@ -565,11 +565,11 @@ public sealed class BotConfig { switch (botConfig.PasswordFormat) { case ArchiCryptoHelper.ECryptoMethod.AES when ArchiCryptoHelper.HasDefaultCryptKey: - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningDefaultCryptKeyUsedForEncryption, botConfig.PasswordFormat, nameof(SteamPassword))); + ASF.ArchiLogger.LogGenericError(Strings.FormatWarningDefaultCryptKeyUsedForEncryption(botConfig.PasswordFormat, nameof(SteamPassword))); break; case ArchiCryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser when ArchiCryptoHelper.HasDefaultCryptKey: - ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.WarningDefaultCryptKeyUsedForHashing, botConfig.PasswordFormat, nameof(SteamPassword))); + ASF.ArchiLogger.LogGenericInfo(Strings.FormatWarningDefaultCryptKeyUsedForHashing(botConfig.PasswordFormat, nameof(SteamPassword))); break; } diff --git a/ArchiSteamFarm/Steam/Storage/BotDatabase.cs b/ArchiSteamFarm/Steam/Storage/BotDatabase.cs index dc54ded52..38559dc3d 100644 --- a/ArchiSteamFarm/Steam/Storage/BotDatabase.cs +++ b/ArchiSteamFarm/Steam/Storage/BotDatabase.cs @@ -24,7 +24,6 @@ using System; using System.Collections; using System.Collections.Specialized; -using System.Globalization; using System.IO; using System.Linq; using System.Text.Json; @@ -270,7 +269,7 @@ public sealed class BotDatabase : GenericDatabase { string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return null; } @@ -355,7 +354,7 @@ public sealed class BotDatabase : GenericDatabase { Utilities.InBackground(Save); } - private (bool Valid, string? ErrorMessage) CheckValidation() => GamesToRedeemInBackground.Cast().Any(static game => !IsValidGameToRedeemInBackground(game)) ? (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(GamesToRedeemInBackground), string.Join("", GamesToRedeemInBackground))) : (true, null); + private (bool Valid, string? ErrorMessage) CheckValidation() => GamesToRedeemInBackground.Cast().Any(static game => !IsValidGameToRedeemInBackground(game)) ? (false, Strings.FormatErrorConfigPropertyInvalid(nameof(GamesToRedeemInBackground), string.Join("", GamesToRedeemInBackground))) : (true, null); private async void OnObjectModified(object? sender, EventArgs e) { if (string.IsNullOrEmpty(FilePath)) { diff --git a/ArchiSteamFarm/Storage/CrashFile.cs b/ArchiSteamFarm/Storage/CrashFile.cs index 4c68ccd7f..869a7d6fb 100644 --- a/ArchiSteamFarm/Storage/CrashFile.cs +++ b/ArchiSteamFarm/Storage/CrashFile.cs @@ -22,7 +22,6 @@ // limitations under the License. using System; -using System.Globalization; using System.IO; using System.Text.Json.Serialization; using System.Threading.Tasks; @@ -97,7 +96,7 @@ internal sealed class CrashFile : SerializableFile { string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return new CrashFile(filePath); } diff --git a/ArchiSteamFarm/Storage/GlobalConfig.cs b/ArchiSteamFarm/Storage/GlobalConfig.cs index 6078b17f9..c38795d8c 100644 --- a/ArchiSteamFarm/Storage/GlobalConfig.cs +++ b/ArchiSteamFarm/Storage/GlobalConfig.cs @@ -489,46 +489,46 @@ public sealed class GlobalConfig { internal (bool Valid, string? ErrorMessage) CheckValidation() { if (Blacklist.Contains(0)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(Blacklist), 0)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(Blacklist), 0)); } if (ConnectionTimeout == 0) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(ConnectionTimeout), ConnectionTimeout)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(ConnectionTimeout), ConnectionTimeout)); } if (FarmingDelay == 0) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(FarmingDelay), FarmingDelay)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(FarmingDelay), FarmingDelay)); } if (!Enum.IsDefined(IPCPasswordFormat)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(IPCPasswordFormat), IPCPasswordFormat)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(IPCPasswordFormat), IPCPasswordFormat)); } if (MaxFarmingTime == 0) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(MaxFarmingTime), MaxFarmingTime)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(MaxFarmingTime), MaxFarmingTime)); } if (!Enum.IsDefined(OptimizationMode)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(OptimizationMode), OptimizationMode)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OptimizationMode), OptimizationMode)); } if (!Enum.IsDefined(PluginsUpdateMode)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(PluginsUpdateMode), PluginsUpdateMode)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(PluginsUpdateMode), PluginsUpdateMode)); } if (!string.IsNullOrEmpty(SteamMessagePrefix) && !SteamChatMessage.IsValidPrefix(SteamMessagePrefix)) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamMessagePrefix), SteamMessagePrefix)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamMessagePrefix), SteamMessagePrefix)); } if ((SteamOwnerID != 0) && !new SteamID(SteamOwnerID).IsIndividualAccount) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamOwnerID), SteamOwnerID)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamOwnerID), SteamOwnerID)); } if (SteamProtocols is <= 0 or > ProtocolTypes.All) { - return (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(SteamProtocols), SteamProtocols)); + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(SteamProtocols), SteamProtocols)); } - return Enum.IsDefined(UpdateChannel) ? (true, null) : (false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel)); + return Enum.IsDefined(UpdateChannel) ? (true, null) : (false, Strings.FormatErrorConfigPropertyInvalid(nameof(UpdateChannel), UpdateChannel)); } internal static async Task<(GlobalConfig? GlobalConfig, string? LatestJson)> Load(string filePath) { @@ -545,7 +545,7 @@ public sealed class GlobalConfig { json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return (null, null); } @@ -577,7 +577,7 @@ public sealed class GlobalConfig { switch (globalConfig.IPCPasswordFormat) { case ArchiCryptoHelper.EHashingMethod.Pbkdf2 when ArchiCryptoHelper.HasDefaultCryptKey: case ArchiCryptoHelper.EHashingMethod.SCrypt when ArchiCryptoHelper.HasDefaultCryptKey: - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningDefaultCryptKeyUsedForHashing, globalConfig.IPCPasswordFormat, nameof(IPCPassword))); + ASF.ArchiLogger.LogGenericWarning(Strings.FormatWarningDefaultCryptKeyUsedForHashing(globalConfig.IPCPasswordFormat, nameof(IPCPassword))); break; } diff --git a/ArchiSteamFarm/Storage/GlobalDatabase.cs b/ArchiSteamFarm/Storage/GlobalDatabase.cs index 42fe3e10b..3a55402a2 100644 --- a/ArchiSteamFarm/Storage/GlobalDatabase.cs +++ b/ArchiSteamFarm/Storage/GlobalDatabase.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Text.Json; @@ -204,7 +203,7 @@ public sealed class GlobalDatabase : GenericDatabase { string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { - ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); + ASF.ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(nameof(json))); return null; } diff --git a/ArchiSteamFarm/Web/WebBrowser.cs b/ArchiSteamFarm/Web/WebBrowser.cs index 03c8e548d..a95be2c6e 100644 --- a/ArchiSteamFarm/Web/WebBrowser.cs +++ b/ArchiSteamFarm/Web/WebBrowser.cs @@ -26,7 +26,6 @@ using System.Buffers; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -201,7 +200,7 @@ public sealed class WebBrowser : IDisposable { throw; } catch (Exception e) { ArchiLogger.LogGenericWarningException(e); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } finally { @@ -215,8 +214,8 @@ public sealed class WebBrowser : IDisposable { } } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -272,13 +271,13 @@ public sealed class WebBrowser : IDisposable { } ArchiLogger.LogGenericWarningException(e); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); } } } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -336,7 +335,7 @@ public sealed class WebBrowser : IDisposable { } ArchiLogger.LogGenericWarningException(e); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); continue; } @@ -346,7 +345,7 @@ public sealed class WebBrowser : IDisposable { return new ObjectResponse(response); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(obj))); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(obj))); continue; } @@ -355,8 +354,8 @@ public sealed class WebBrowser : IDisposable { } } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -400,8 +399,8 @@ public sealed class WebBrowser : IDisposable { return new StreamResponse(response, await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false)); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -444,8 +443,8 @@ public sealed class WebBrowser : IDisposable { return new BasicResponse(response); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -488,8 +487,8 @@ public sealed class WebBrowser : IDisposable { return new BasicResponse(response); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -545,13 +544,13 @@ public sealed class WebBrowser : IDisposable { } ArchiLogger.LogGenericWarningException(e); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); } } } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -609,7 +608,7 @@ public sealed class WebBrowser : IDisposable { } ArchiLogger.LogGenericWarningException(e); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); continue; } @@ -619,7 +618,7 @@ public sealed class WebBrowser : IDisposable { return new ObjectResponse(response); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(obj))); + ArchiLogger.LogGenericWarning(Strings.FormatErrorIsEmpty(nameof(obj))); continue; } @@ -628,8 +627,8 @@ public sealed class WebBrowser : IDisposable { } } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -673,8 +672,8 @@ public sealed class WebBrowser : IDisposable { return new StreamResponse(response, await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false)); } - ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, maxTries)); - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.ErrorFailingRequest, request)); + ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(maxTries)); + ArchiLogger.LogGenericDebug(Strings.FormatErrorFailingRequest(request)); return null; } @@ -837,7 +836,7 @@ public sealed class WebBrowser : IDisposable { return response; default: // We have no clue about those, but maybe HttpClient can handle them for us - ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(redirectUri.Scheme), redirectUri.Scheme)); + ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(redirectUri.Scheme), redirectUri.Scheme)); break; } @@ -881,7 +880,7 @@ public sealed class WebBrowser : IDisposable { if (response.StatusCode.IsClientErrorCode()) { if (Debugging.IsUserDebugging) { - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); + ArchiLogger.LogGenericDebug(Strings.FormatContent(await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); } // Do not retry on client errors @@ -890,7 +889,7 @@ public sealed class WebBrowser : IDisposable { if (requestOptions.HasFlag(ERequestOptions.ReturnServerErrors) && response.StatusCode.IsServerErrorCode()) { if (Debugging.IsUserDebugging) { - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); + ArchiLogger.LogGenericDebug(Strings.FormatContent(await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); } // Do not retry on server errors in this case @@ -899,7 +898,7 @@ public sealed class WebBrowser : IDisposable { using (response) { if (Debugging.IsUserDebugging) { - ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.Content, await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); + ArchiLogger.LogGenericDebug(Strings.FormatContent(await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false))); } return null;