diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index a6ad38e25..1338c78e4 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -56,14 +56,19 @@ namespace ArchiSteamFarm { private readonly string SentryFile; private readonly BotDatabase BotDatabase; private readonly CallbackManager CallbackManager; + + [JsonProperty] private readonly CardsFarmer CardsFarmer; + private readonly SteamApps SteamApps; private readonly SteamFriends SteamFriends; private readonly SteamUser SteamUser; private readonly Timer AcceptConfirmationsTimer, SendItemsTimer; private readonly Trading Trading; + [JsonProperty] internal bool KeepRunning { get; private set; } + internal bool PlayingBlocked { get; private set; } private bool FirstTradeSent, InvalidPassword, SkipFirstShutdown; @@ -354,6 +359,8 @@ namespace ArchiSteamFarm { return await Response2FAConfirm(steamID, false).ConfigureAwait(false); case "!2faok": return await Response2FAConfirm(steamID, true).ConfigureAwait(false); + case "!api": + return ResponseAPI(steamID); case "!exit": return ResponseExit(steamID); case "!farm": @@ -754,6 +761,24 @@ namespace ArchiSteamFarm { return null; } + private static string ResponseAPI(ulong steamID) { + if (steamID == 0) { + Logging.LogNullError(nameof(steamID)); + return null; + } + + if (!IsOwner(steamID)) { + return null; + } + + try { + return JsonConvert.SerializeObject(Bots); + } catch (JsonException e) { + Logging.LogGenericException(e); + return null; + } + } + private static string ResponseExit(ulong steamID) { if (steamID == 0) { Logging.LogNullError(nameof(steamID)); diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 7865fe69b..9a1faa78c 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -31,10 +31,14 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; namespace ArchiSteamFarm { internal sealed class CardsFarmer { + [JsonProperty] internal readonly ConcurrentDictionary GamesToFarm = new ConcurrentDictionary(); + + [JsonProperty] internal readonly ConcurrentHashSet CurrentGamesFarming = new ConcurrentHashSet(); private readonly ManualResetEventSlim FarmResetEvent = new ManualResetEventSlim(false); @@ -42,6 +46,7 @@ namespace ArchiSteamFarm { private readonly Bot Bot; private readonly Timer Timer; + [JsonProperty] internal bool ManualMode { get; private set; } private bool KeepFarming, NowFarming;