Remove steam awards voting

We do not intend to keep it in mainline as the API is unstable and too sale-specific.
This commit is contained in:
JustArchi
2018-12-26 02:56:38 +01:00
parent c73536733a
commit c5aae8d534
3 changed files with 1 additions and 106 deletions

View File

@@ -879,12 +879,6 @@ namespace ArchiSteamFarm {
return result;
}
internal async Task<HtmlDocument> GetSteamAwardsPage() {
const string request = "/SteamAwards?l=english";
return await UrlGetToHtmlDocumentWithSession(SteamStoreURL, request).ConfigureAwait(false);
}
internal async Task<byte?> GetTradeHoldDurationForTrade(ulong tradeID) {
if (tradeID == 0) {
Bot.ArchiLogger.LogNullError(nameof(tradeID));
@@ -1374,24 +1368,6 @@ namespace ArchiSteamFarm {
return (true, mobileTradeOfferIDs);
}
internal async Task<bool> SteamAwardsVote(byte voteID, uint appID) {
if ((voteID == 0) || (appID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(voteID) + " || " + nameof(appID));
return false;
}
const string request = "/salevote";
// Extra entry for sessionID
Dictionary<string, string> data = new Dictionary<string, string>(3) {
{ "appid", appID.ToString() },
{ "voteid", voteID.ToString() }
};
return await UrlPostWithSession(SteamStoreURL, request, data).ConfigureAwait(false);
}
internal async Task<bool> UnpackBooster(uint appID, ulong itemID) {
if ((appID == 0) || (itemID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(itemID));

View File

@@ -37,7 +37,7 @@ namespace ArchiSteamFarm {
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
SaleEventTimer = new Timer(
async e => await Task.WhenAll(ExploreDiscoveryQueue(), VoteForSteamAwards()).ConfigureAwait(false),
async e => await ExploreDiscoveryQueue().ConfigureAwait(false),
null,
TimeSpan.FromHours(1.1) + TimeSpan.FromSeconds(Program.LoadBalancingDelay * Bot.Bots.Count), // Delay
TimeSpan.FromHours(8.1) // Period
@@ -108,70 +108,5 @@ namespace ArchiSteamFarm {
// It'd make more sense to check against "Come back tomorrow", but it might not cover out-of-the-event queue
return text.StartsWith("You can get ", StringComparison.Ordinal);
}
private async Task VoteForSteamAwards() {
if (!Bot.IsConnectedAndLoggedOn) {
return;
}
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetSteamAwardsPage().ConfigureAwait(false);
HtmlNodeCollection nominationNodes = htmlDocument?.DocumentNode.SelectNodes("//div[@class='vote_nominations store_horizontal_autoslider']");
if (nominationNodes == null) {
// Event ended, error or likewise
return;
}
foreach (HtmlNode nominationNode in nominationNodes) {
HtmlNode myVoteNode = nominationNode.SelectSingleNode("./div[@class='vote_nomination your_vote']");
if (myVoteNode != null) {
// Already voted
continue;
}
string voteIDText = nominationNode.GetAttributeValue("data-voteid", null);
if (string.IsNullOrEmpty(voteIDText)) {
Bot.ArchiLogger.LogNullError(nameof(voteIDText));
return;
}
if (!byte.TryParse(voteIDText, out byte voteID) || (voteID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(voteID));
return;
}
HtmlNodeCollection voteNodes = nominationNode.SelectNodes("./div[starts-with(@class, 'vote_nomination')]");
if (voteNodes == null) {
Bot.ArchiLogger.LogNullError(nameof(voteNodes));
return;
}
// Random a game we'll actually vote for, we don't want to make anybody angry by rigging votes...
HtmlNode voteNode = voteNodes[Utilities.RandomNext(voteNodes.Count)];
string appIDText = voteNode.GetAttributeValue("data-vote-appid", null);
if (string.IsNullOrEmpty(appIDText)) {
Bot.ArchiLogger.LogNullError(nameof(appIDText));
return;
}
if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(appID));
return;
}
await Bot.ArchiWebHandler.SteamAwardsVote(voteID, appID).ConfigureAwait(false);
}
}
}
}

View File

@@ -199,22 +199,6 @@ namespace ArchiSteamFarm {
}
}
internal static int RandomNext(int maxWithout) {
if (maxWithout <= 0) {
ASF.ArchiLogger.LogNullError(nameof(maxWithout));
return -1;
}
if (maxWithout == 1) {
return 0;
}
lock (Random) {
return Random.Next(maxWithout);
}
}
internal static string ReadLineMasked(char mask = '*') {
StringBuilder result = new StringBuilder();