First set of fixes

This commit is contained in:
JustArchi
2016-12-04 05:50:11 +01:00
parent 2147aed1d4
commit 2165818e25
6 changed files with 9 additions and 7 deletions

View File

@@ -35,6 +35,7 @@ using HtmlAgilityPack;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamKit2;
using Formatting = Newtonsoft.Json.Formatting;
namespace ArchiSteamFarm {
internal sealed class ArchiWebHandler : IDisposable {
@@ -847,7 +848,7 @@ namespace ArchiSteamFarm {
{ "partner", partnerID.ToString() },
{ "tradeoffermessage", "Sent by ASF" },
{ "json_tradeoffer", JsonConvert.SerializeObject(trade) },
{ "trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : new JObject { { "trade_offer_access_token", token } }.ToString(Newtonsoft.Json.Formatting.None) }
{ "trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : new JObject { { "trade_offer_access_token", token } }.ToString(Formatting.None) }
})) {
if (!await WebBrowser.UrlPostRetry(request, data, referer).ConfigureAwait(false)) {
return false;

View File

@@ -56,12 +56,13 @@ namespace ArchiSteamFarm {
internal readonly ArchiWebHandler ArchiWebHandler;
internal readonly string BotName;
internal bool HasMobileAuthenticator => BotDatabase.MobileAuthenticator != null;
internal bool IsConnectedAndLoggedOn => SteamClient.IsConnected && (SteamClient.SteamID != null);
internal bool HasMobileAuthenticator => BotDatabase?.MobileAuthenticator != null;
internal bool HasValidApiKey => !string.IsNullOrEmpty(BotConfig?.SteamApiKey) && (BotConfig.SteamApiKey.Length == 32);
internal bool IsConnectedAndLoggedOn => (SteamClient?.IsConnected == true) && (SteamClient.SteamID != null);
internal bool IsPlayingPossible => !PlayingBlocked && (LibraryLockedBySteamID == 0);
[JsonProperty]
internal ulong SteamID => SteamClient.SteamID ?? 0;
internal ulong SteamID => SteamClient?.SteamID ?? 0;
private readonly BotDatabase BotDatabase;
private readonly CallbackManager CallbackManager;
@@ -1713,7 +1714,7 @@ namespace ArchiSteamFarm {
}
Dictionary<uint, string> ownedGames;
if (!string.IsNullOrEmpty(BotConfig.SteamApiKey)) {
if (HasValidApiKey) {
ownedGames = ArchiWebHandler.GetOwnedGames(SteamClient.SteamID);
} else {
ownedGames = await ArchiWebHandler.GetOwnedGames().ConfigureAwait(false);

View File

@@ -83,7 +83,7 @@ namespace ArchiSteamFarm {
const string request = SharedInfo.StatisticsServer + "/api/LoggedOn";
Dictionary<string, string> data = new Dictionary<string, string>(4) {
{ "SteamID", Bot.SteamID.ToString() },
{ "HasMobileAuthenticator", Bot.HasMobileAuthenticator ? "1" : "0" },
{ "HasAutomatedTrading", Bot.HasMobileAuthenticator && Bot.HasValidApiKey ? "1" : "0" },
{ "SteamTradeMatcher", Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher) ? "1" : "0" },
{ "MatchEverything", Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) ? "1" : "0" }
};

View File

@@ -90,7 +90,7 @@ namespace ArchiSteamFarm {
internal void OnDisconnected() => IgnoredTrades.ClearAndTrim();
private async Task ParseActiveTrades() {
if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
if (!Bot.HasValidApiKey) {
return;
}

Binary file not shown.

Binary file not shown.