From cd0d0a94a18d76139009a75cc44883abe95ec5e5 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 28 Oct 2015 22:34:53 +0100 Subject: [PATCH] Add support for blacklist feature, fix SMG --- ArchiSteamFarm/ArchiWebHandler.cs | 21 ++++++++++++--------- ArchiSteamFarm/Bot.cs | 10 ++++++++++ ArchiSteamFarm/CardsFarmer.cs | 4 ++++ ArchiSteamFarm/Trading.cs | 1 - ArchiSteamFarm/config/example.xml | 3 +++ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index cc6fef49bde78..42b76cae0918c 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -47,8 +47,9 @@ private string GetHomeProcess() { return "http://steamcommunity.com/id/" + VanityURL + "/home_process"; } else if (SteamID != 0) { return "http://steamcommunity.com/profiles/" + SteamID + "/home_process"; + } else { + return null; } - return null; } internal ArchiWebHandler(Bot bot, string apiKey) { @@ -195,6 +196,7 @@ internal List GetTradeOffers() { } result.Add(tradeOffer); } + return result; } @@ -266,23 +268,24 @@ internal async Task LeaveClan(ulong clanID) { {"action", "leaveGroup"}, {"groupId", clanID.ToString()} }; + await Utilities.UrlPostRequest(request, postData, SteamCookieDictionary).ConfigureAwait(false); } internal async Task GetBadgePage(int page) { - HtmlDocument result = null; - if (SteamID != 0 && page != 0) { - result = await Utilities.UrlToHtmlDocument("http://steamcommunity.com/profiles/" + SteamID + "/badges?p=" + page, SteamCookieDictionary).ConfigureAwait(false); + if (SteamID == 0 || page == 0) { + return null; } - return result; + + return await Utilities.UrlToHtmlDocument("http://steamcommunity.com/profiles/" + SteamID + "/badges?p=" + page, SteamCookieDictionary).ConfigureAwait(false); } internal async Task GetGameCardsPage(ulong appID) { - HtmlDocument result = null; - if (SteamID != 0 && appID != 0) { - result = await Utilities.UrlToHtmlDocument("http://steamcommunity.com/profiles/" + SteamID + "/gamecards/" + appID, SteamCookieDictionary).ConfigureAwait(false); + if (SteamID == 0 || appID == 0) { + return null; } - return result; + + return await Utilities.UrlToHtmlDocument("http://steamcommunity.com/profiles/" + SteamID + "/gamecards/" + appID, SteamCookieDictionary).ConfigureAwait(false); } } } diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 505f86e61320b..7f0fc73f351d2 100644 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -62,6 +62,7 @@ internal class Bot { private string SteamApiKey { get { return Config["SteamApiKey"]; } } internal ulong SteamMasterID { get { return ulong.Parse(Config["SteamMasterID"]); } } private ulong SteamMasterClanID { get { return ulong.Parse(Config["SteamMasterClanID"]); } } + internal HashSet Blacklist { get; } = new HashSet(); internal Bot(string botName) { BotName = botName; @@ -97,6 +98,14 @@ private void ReadConfig() { } Config.Add(key, value); + + switch (key) { + case "Blacklist": + foreach (string appID in value.Split(',')) { + Blacklist.Add(uint.Parse(appID)); + } + break; + } } } } @@ -187,6 +196,7 @@ private void OnDisconnected(SteamClient.DisconnectedCallback callback) { if (callback == null) { return; } + if (SteamClient == null) { return; } diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 5f15e9e3edac0..81bcee77c669a 100644 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -84,6 +84,10 @@ internal async Task StartFarming() { continue; } + if (Bot.Blacklist.Contains(appID)) { + continue; + } + appIDs.Add(appID); } } diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index 3d0164bddbef1..404f19a722bf7 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -37,7 +37,6 @@ internal Trading(Bot bot) { } internal void CheckTrades() { - Logging.LogGenericDebug(""); if (ParsingTasks < 2) { ParsingTasks++; Task.Run(() => ParseActiveTrades()); diff --git a/ArchiSteamFarm/config/example.xml b/ArchiSteamFarm/config/example.xml index 34aa8de5494da..7bf8b56bcfd19 100644 --- a/ArchiSteamFarm/config/example.xml +++ b/ArchiSteamFarm/config/example.xml @@ -24,4 +24,7 @@ + + + \ No newline at end of file