This commit is contained in:
JustArchi
2016-06-20 21:20:38 +02:00
parent 92f347e28b
commit 41f8a0a474
2 changed files with 30 additions and 0 deletions

View File

@@ -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));

View File

@@ -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<uint, float> GamesToFarm = new ConcurrentDictionary<uint, float>();
[JsonProperty]
internal readonly ConcurrentHashSet<uint> CurrentGamesFarming = new ConcurrentHashSet<uint>();
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;