diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index 2065a63c7..78aa02191 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -183,7 +183,7 @@ namespace ArchiSteamFarm { } } - if (targetSteamID == Bot.CachedSteamID) { + if (targetSteamID == Bot.SteamID) { return (false, Strings.BotSendingTradeToYourself); } @@ -202,7 +202,7 @@ namespace ArchiSteamFarm { LootingScheduled = false; } - HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.CachedSteamID, appID, contextID, true, wantedTypes, wantedRealAppIDs).ConfigureAwait(false); + HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.SteamID, appID, contextID, true, wantedTypes, wantedRealAppIDs).ConfigureAwait(false); if ((inventory == null) || (inventory.Count == 0)) { return (false, string.Format(Strings.ErrorIsEmpty, nameof(inventory))); } @@ -325,7 +325,7 @@ namespace ArchiSteamFarm { return (true, version); } - private ulong GetFirstSteamMasterID() => Bot.BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderByDescending(steamID => steamID != Bot.CachedSteamID).ThenBy(steamID => steamID).FirstOrDefault(); + private ulong GetFirstSteamMasterID() => Bot.BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderByDescending(steamID => steamID != Bot.SteamID).ThenBy(steamID => steamID).FirstOrDefault(); private static async Task LimitGiftsRequestsAsync() { if (Program.GlobalConfig.GiftsLimiterDelay == 0) { diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index e45887fe8..4be206db8 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -81,7 +81,9 @@ namespace ArchiSteamFarm { internal bool HasMobileAuthenticator => BotDatabase?.MobileAuthenticator != null; internal bool IsAccountLimited => AccountFlags.HasFlag(EAccountFlags.LimitedUser) || AccountFlags.HasFlag(EAccountFlags.LimitedUserForce); internal bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown); - internal bool IsConnectedAndLoggedOn => SteamID != 0; + + [JsonProperty] + internal bool IsConnectedAndLoggedOn => SteamClient?.SteamID != null; [JsonProperty] internal bool IsPlayingPossible => !PlayingBlocked && (LibraryLockedBySteamID == 0); @@ -110,19 +112,15 @@ namespace ArchiSteamFarm { [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamID))] private string SSteamID => SteamID.ToString(); - [JsonProperty] - private ulong SteamID => SteamClient?.SteamID ?? 0; - [JsonProperty] internal BotConfig BotConfig { get; private set; } - internal ulong CachedSteamID { get; private set; } - [JsonProperty] internal bool KeepRunning { get; private set; } internal bool PlayingBlocked { get; private set; } internal bool PlayingWasBlocked { get; private set; } + internal ulong SteamID { get; private set; } [JsonProperty] private EAccountFlags AccountFlags; @@ -606,7 +604,7 @@ namespace ArchiSteamFarm { return await ArchiWebHandler.GetTradeHoldDurationForUser(steamID).ConfigureAwait(false); } - Bot targetBot = Bots.Values.FirstOrDefault(bot => bot.CachedSteamID == steamID); + Bot targetBot = Bots.Values.FirstOrDefault(bot => bot.SteamID == steamID); if (targetBot != null) { string targetTradeToken = await targetBot.ArchiWebHandler.GetTradeToken().ConfigureAwait(false); if (!string.IsNullOrEmpty(targetTradeToken)) { @@ -828,7 +826,7 @@ namespace ArchiSteamFarm { return false; } - if (await ArchiWebHandler.Init(CachedSteamID, SteamClient.Universe, callback.Nonce, BotConfig.SteamParentalCode).ConfigureAwait(false)) { + if (await ArchiWebHandler.Init(SteamID, SteamClient.Universe, callback.Nonce, BotConfig.SteamParentalCode).ConfigureAwait(false)) { return true; } @@ -892,7 +890,7 @@ namespace ArchiSteamFarm { return; } - SteamFriends.RequestFriendInfo(CachedSteamID, EClientPersonaStateFlag.PlayerName | EClientPersonaStateFlag.Presence); + SteamFriends.RequestFriendInfo(SteamID, EClientPersonaStateFlag.PlayerName | EClientPersonaStateFlag.Presence); } internal async Task SendMessage(ulong steamID, string message) { @@ -1683,7 +1681,7 @@ namespace ArchiSteamFarm { return; } - if ((notification.steamid_sender != CachedSteamID) && BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkReceivedMessagesAsRead)) { + if ((notification.steamid_sender != SteamID) && BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkReceivedMessagesAsRead)) { Utilities.InBackground(() => ArchiHandler.AckChatMessage(notification.chat_group_id, notification.chat_id, notification.timestamp)); } @@ -1879,9 +1877,9 @@ namespace ArchiSteamFarm { break; case EResult.OK: AccountFlags = callback.AccountFlags; - CachedSteamID = callback.ClientSteamID; + SteamID = callback.ClientSteamID; - ArchiLogger.LogGenericInfo(string.Format(Strings.BotLoggedOn, CachedSteamID + (!string.IsNullOrEmpty(callback.VanityURL) ? "/" + callback.VanityURL : ""))); + ArchiLogger.LogGenericInfo(string.Format(Strings.BotLoggedOn, SteamID + (!string.IsNullOrEmpty(callback.VanityURL) ? "/" + callback.VanityURL : ""))); // Old status for these doesn't matter, we'll update them if needed LibraryLockedBySteamID = TwoFactorCodeFailures = 0; @@ -2067,7 +2065,7 @@ namespace ArchiSteamFarm { return; } - if (callback.FriendID == CachedSteamID) { + if (callback.FriendID == SteamID) { string avatarHash = null; if ((callback.AvatarHash != null) && (callback.AvatarHash.Length > 0) && callback.AvatarHash.Any(singleByte => singleByte != 0)) { @@ -2127,13 +2125,13 @@ namespace ArchiSteamFarm { // Ignore no status updates if (LibraryLockedBySteamID == 0) { - if ((callback.LibraryLockedBySteamID == 0) || (callback.LibraryLockedBySteamID == CachedSteamID)) { + if ((callback.LibraryLockedBySteamID == 0) || (callback.LibraryLockedBySteamID == SteamID)) { return; } LibraryLockedBySteamID = callback.LibraryLockedBySteamID; } else { - if ((callback.LibraryLockedBySteamID != 0) && (callback.LibraryLockedBySteamID != CachedSteamID)) { + if ((callback.LibraryLockedBySteamID != 0) && (callback.LibraryLockedBySteamID != SteamID)) { return; } diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index 3c379dcb7..6ba74c392 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -1252,7 +1252,7 @@ namespace ArchiSteamFarm { } if (ownedGames == null) { - ownedGames = await Bot.ArchiWebHandler.HasValidApiKey().ConfigureAwait(false) ? await Bot.ArchiWebHandler.GetOwnedGames(Bot.CachedSteamID).ConfigureAwait(false) : await Bot.ArchiWebHandler.GetMyOwnedGames().ConfigureAwait(false); + ownedGames = await Bot.ArchiWebHandler.HasValidApiKey().ConfigureAwait(false) ? await Bot.ArchiWebHandler.GetOwnedGames(Bot.SteamID).ConfigureAwait(false) : await Bot.ArchiWebHandler.GetMyOwnedGames().ConfigureAwait(false); if ((ownedGames == null) || (ownedGames.Count == 0)) { return (FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(ownedGames))), null); } @@ -2035,7 +2035,7 @@ namespace ArchiSteamFarm { return FormatBotResponse(Strings.BotNotConnected); } - if (targetBot.CachedSteamID == Bot.CachedSteamID) { + if (targetBot.SteamID == Bot.SteamID) { return FormatBotResponse(Strings.BotSendingTradeToYourself); } @@ -2089,7 +2089,7 @@ namespace ArchiSteamFarm { } } - (bool success, string output) = await Bot.Actions.Loot(targetSteamID: targetBot.CachedSteamID, wantedTypes: transferTypes).ConfigureAwait(false); + (bool success, string output) = await Bot.Actions.Loot(targetSteamID: targetBot.SteamID, wantedTypes: transferTypes).ConfigureAwait(false); return FormatBotResponse(success ? output : string.Format(Strings.WarningFailedWithError, output)); } @@ -2133,7 +2133,7 @@ namespace ArchiSteamFarm { return FormatBotResponse(Strings.BotNotConnected); } - HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.CachedSteamID, wantedTypes: new HashSet { Steam.Asset.EType.BoosterPack }).ConfigureAwait(false); + HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.SteamID, wantedTypes: new HashSet { Steam.Asset.EType.BoosterPack }).ConfigureAwait(false); if ((inventory == null) || (inventory.Count == 0)) { return FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(inventory))); } diff --git a/ArchiSteamFarm/NLog/SteamTarget.cs b/ArchiSteamFarm/NLog/SteamTarget.cs index 27822a935..1323e2b3f 100644 --- a/ArchiSteamFarm/NLog/SteamTarget.cs +++ b/ArchiSteamFarm/NLog/SteamTarget.cs @@ -81,7 +81,7 @@ namespace ArchiSteamFarm.NLog { if (ChatGroupID != 0) { await SendGroupMessage(message, bot).ConfigureAwait(false); - } else if ((bot == null) || (bot.CachedSteamID != SteamID)) { + } else if ((bot == null) || (bot.SteamID != SteamID)) { await SendPrivateMessage(message, bot).ConfigureAwait(false); } } @@ -110,7 +110,7 @@ namespace ArchiSteamFarm.NLog { } if (bot == null) { - bot = Bot.Bots.Values.FirstOrDefault(targetBot => targetBot.IsConnectedAndLoggedOn && (targetBot.CachedSteamID != SteamID)); + bot = Bot.Bots.Values.FirstOrDefault(targetBot => targetBot.IsConnectedAndLoggedOn && (targetBot.SteamID != SteamID)); if (bot == null) { return; diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 13077f24d..73553fbc2 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -74,7 +74,7 @@ namespace ArchiSteamFarm { const string request = URL + "/Api/HeartBeat"; Dictionary data = new Dictionary(2) { - { "SteamID", Bot.CachedSteamID.ToString() }, + { "SteamID", Bot.SteamID.ToString() }, { "Guid", Program.GlobalDatabase.Guid.ToString("N") } }; @@ -116,7 +116,7 @@ namespace ArchiSteamFarm { return; } - HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.CachedSteamID, tradable: true, wantedTypes: acceptedMatchableTypes).ConfigureAwait(false); + HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.SteamID, tradable: true, wantedTypes: acceptedMatchableTypes).ConfigureAwait(false); // This is actually inventory failure, so we'll stop sending heartbeats but not record it as valid check if (inventory == null) { @@ -133,7 +133,7 @@ namespace ArchiSteamFarm { const string request = URL + "/Api/Announce"; Dictionary data = new Dictionary(9) { - { "SteamID", Bot.CachedSteamID.ToString() }, + { "SteamID", Bot.SteamID.ToString() }, { "Guid", Program.GlobalDatabase.Guid.ToString("N") }, { "Nickname", nickname ?? "" }, { "AvatarHash", avatarHash ?? "" }, diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index c857014b8..13b69d989 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -304,7 +304,7 @@ namespace ArchiSteamFarm { } // Otherwise we either accept donations but not bot trades, or we accept bot trades but not donations - bool isBotTrade = (tradeOffer.OtherSteamID64 != 0) && Bot.Bots.Values.Any(bot => bot.CachedSteamID == tradeOffer.OtherSteamID64); + bool isBotTrade = (tradeOffer.OtherSteamID64 != 0) && Bot.Bots.Values.Any(bot => bot.SteamID == tradeOffer.OtherSteamID64); return new ParseTradeResult(tradeOffer.TradeOfferID, (acceptDonations && !isBotTrade) || (acceptBotTrades && isBotTrade) ? ParseTradeResult.EResult.AcceptedWithoutItemLose : ParseTradeResult.EResult.RejectedPermanently); } @@ -355,7 +355,7 @@ namespace ArchiSteamFarm { } // Now check if it's worth for us to do the trade - HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.CachedSteamID, wantedTypes: types, wantedRealAppIDs: appIDs).ConfigureAwait(false); + HashSet inventory = await Bot.ArchiWebHandler.GetInventory(Bot.SteamID, wantedTypes: types, wantedRealAppIDs: appIDs).ConfigureAwait(false); if ((inventory == null) || (inventory.Count == 0)) { // If we can't check our inventory when not using MatchEverything, this is a temporary failure Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.ErrorIsEmpty, nameof(inventory)));