Skip to content

Commit

Permalink
Add support for blacklist feature, fix SMG
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Oct 28, 2015
1 parent 639067d commit cd0d0a9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
21 changes: 12 additions & 9 deletions ArchiSteamFarm/ArchiWebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -195,6 +196,7 @@ internal List<SteamTradeOffer> GetTradeOffers() {
}
result.Add(tradeOffer);
}

return result;
}

Expand Down Expand Up @@ -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<HtmlDocument> 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<HtmlDocument> 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);
}
}
}
10 changes: 10 additions & 0 deletions ArchiSteamFarm/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint> Blacklist { get; } = new HashSet<uint>();

internal Bot(string botName) {
BotName = botName;
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -187,6 +196,7 @@ private void OnDisconnected(SteamClient.DisconnectedCallback callback) {
if (callback == null) {
return;
}

if (SteamClient == null) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions ArchiSteamFarm/CardsFarmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ internal async Task StartFarming() {
continue;
}

if (Bot.Blacklist.Contains(appID)) {
continue;
}

appIDs.Add(appID);
}
}
Expand Down
1 change: 0 additions & 1 deletion ArchiSteamFarm/Trading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ internal Trading(Bot bot) {
}

internal void CheckTrades() {
Logging.LogGenericDebug("");
if (ParsingTasks < 2) {
ParsingTasks++;
Task.Run(() => ParseActiveTrades());
Expand Down
3 changes: 3 additions & 0 deletions ArchiSteamFarm/config/example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<!-- If you want from the bot to join particular chat of given clan, set it here, otherwise leave at 0 -->
<SteamMasterClanID type="ulong" value="0"/>

<!-- Comma-separated list of IDs that should not be considered for farming -->
<Blacklist type="HashSet<uint>" value="368020"/>

</configuration>

0 comments on commit cd0d0a9

Please sign in to comment.