mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Cleanup old winter sale code
This commit is contained in:
@@ -137,7 +137,6 @@ namespace ArchiSteamFarm {
|
|||||||
return htmlDocument?.DocumentNode.SelectSingleNode("//div[@class='add_free_content_success_area']") != null;
|
return htmlDocument?.DocumentNode.SelectSingleNode("//div[@class='add_free_content_success_area']") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal async Task<bool> ClearFromDiscoveryQueue(uint appID) {
|
internal async Task<bool> ClearFromDiscoveryQueue(uint appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
Bot.ArchiLogger.LogNullError(nameof(appID));
|
Bot.ArchiLogger.LogNullError(nameof(appID));
|
||||||
@@ -162,7 +161,6 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
|
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
internal async Task DeclineTradeOffer(ulong tradeID) {
|
internal async Task DeclineTradeOffer(ulong tradeID) {
|
||||||
if (tradeID == 0) {
|
if (tradeID == 0) {
|
||||||
@@ -199,7 +197,6 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal async Task<HashSet<uint>> GenerateNewDiscoveryQueue() {
|
internal async Task<HashSet<uint>> GenerateNewDiscoveryQueue() {
|
||||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -220,7 +217,6 @@ namespace ArchiSteamFarm {
|
|||||||
Steam.NewDiscoveryQueueResponse output = await WebBrowser.UrlPostToJsonResultRetry<Steam.NewDiscoveryQueueResponse>(request, data).ConfigureAwait(false);
|
Steam.NewDiscoveryQueueResponse output = await WebBrowser.UrlPostToJsonResultRetry<Steam.NewDiscoveryQueueResponse>(request, data).ConfigureAwait(false);
|
||||||
return output?.Queue;
|
return output?.Queue;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
internal async Task<HashSet<Steam.TradeOffer>> GetActiveTradeOffers() {
|
internal async Task<HashSet<Steam.TradeOffer>> GetActiveTradeOffers() {
|
||||||
string steamApiKey = await GetApiKey().ConfigureAwait(false);
|
string steamApiKey = await GetApiKey().ConfigureAwait(false);
|
||||||
@@ -384,7 +380,6 @@ namespace ArchiSteamFarm {
|
|||||||
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal async Task<HtmlDocument> GetDiscoveryQueuePage() {
|
internal async Task<HtmlDocument> GetDiscoveryQueuePage() {
|
||||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -393,7 +388,6 @@ namespace ArchiSteamFarm {
|
|||||||
const string request = SteamStoreURL + "/explore?l=english";
|
const string request = SteamStoreURL + "/explore?l=english";
|
||||||
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
internal async Task<HashSet<ulong>> GetFamilySharingSteamIDs() {
|
internal async Task<HashSet<ulong>> GetFamilySharingSteamIDs() {
|
||||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
||||||
@@ -688,17 +682,6 @@ namespace ArchiSteamFarm {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal async Task<HtmlDocument> GetSteamAwardsPage() {
|
|
||||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const string request = SteamStoreURL + "/SteamAwards?l=english";
|
|
||||||
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
internal async Task<byte?> GetTradeHoldDuration(ulong tradeID) {
|
internal async Task<byte?> GetTradeHoldDuration(ulong tradeID) {
|
||||||
if (tradeID == 0) {
|
if (tradeID == 0) {
|
||||||
Bot.ArchiLogger.LogNullError(nameof(tradeID));
|
Bot.ArchiLogger.LogNullError(nameof(tradeID));
|
||||||
@@ -1170,34 +1153,6 @@ namespace ArchiSteamFarm {
|
|||||||
return (ESteamApiKeyState.Error, null);
|
return (ESteamApiKeyState.Error, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
internal async Task<bool> SteamAwardsVote(byte voteID, uint appID) {
|
|
||||||
if ((voteID == 0) || (appID == 0)) {
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(voteID) + " || " + nameof(appID));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamStoreURL, "sessionid");
|
|
||||||
if (string.IsNullOrEmpty(sessionID)) {
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(sessionID));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const string request = SteamStoreURL + "/salevote";
|
|
||||||
Dictionary<string, string> data = new Dictionary<string, string>(3) {
|
|
||||||
{ "sessionid", sessionID },
|
|
||||||
{ "voteid", voteID.ToString() },
|
|
||||||
{ "appid", appID.ToString() }
|
|
||||||
};
|
|
||||||
|
|
||||||
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static uint GetAppIDFromMarketHashName(string hashName) {
|
private static uint GetAppIDFromMarketHashName(string hashName) {
|
||||||
if (string.IsNullOrEmpty(hashName)) {
|
if (string.IsNullOrEmpty(hashName)) {
|
||||||
ASF.ArchiLogger.LogNullError(nameof(hashName));
|
ASF.ArchiLogger.LogNullError(nameof(hashName));
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly SteamClient SteamClient;
|
private readonly SteamClient SteamClient;
|
||||||
private readonly ConcurrentHashSet<ulong> SteamFamilySharingIDs = new ConcurrentHashSet<ulong>();
|
private readonly ConcurrentHashSet<ulong> SteamFamilySharingIDs = new ConcurrentHashSet<ulong>();
|
||||||
private readonly SteamFriends SteamFriends;
|
private readonly SteamFriends SteamFriends;
|
||||||
//private readonly SteamSaleEvent SteamSaleEvent;
|
private readonly SteamSaleEvent SteamSaleEvent;
|
||||||
private readonly SteamUser SteamUser;
|
private readonly SteamUser SteamUser;
|
||||||
private readonly Trading Trading;
|
private readonly Trading Trading;
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
ArchiWebHandler = new ArchiWebHandler(this);
|
ArchiWebHandler = new ArchiWebHandler(this);
|
||||||
CardsFarmer = new CardsFarmer(this);
|
CardsFarmer = new CardsFarmer(this);
|
||||||
//SteamSaleEvent = new SteamSaleEvent(this);
|
SteamSaleEvent = new SteamSaleEvent(this);
|
||||||
Trading = new Trading(this);
|
Trading = new Trading(this);
|
||||||
|
|
||||||
if (!Debugging.IsDebugBuild && Program.GlobalConfig.Statistics) {
|
if (!Debugging.IsDebugBuild && Program.GlobalConfig.Statistics) {
|
||||||
@@ -235,7 +235,7 @@ namespace ArchiSteamFarm {
|
|||||||
HeartBeatTimer.Dispose();
|
HeartBeatTimer.Dispose();
|
||||||
CallbackSemaphore.Dispose();
|
CallbackSemaphore.Dispose();
|
||||||
InitializationSemaphore.Dispose();
|
InitializationSemaphore.Dispose();
|
||||||
//SteamSaleEvent.Dispose();
|
SteamSaleEvent.Dispose();
|
||||||
Trading.Dispose();
|
Trading.Dispose();
|
||||||
|
|
||||||
// Those are objects that might be null and the check should be in-place
|
// Those are objects that might be null and the check should be in-place
|
||||||
|
|||||||
@@ -354,7 +354,6 @@ namespace ArchiSteamFarm.JSON {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deserialized from JSON
|
// Deserialized from JSON
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
|
||||||
private Item() { }
|
private Item() { }
|
||||||
|
|
||||||
internal enum EType : byte {
|
internal enum EType : byte {
|
||||||
@@ -368,7 +367,6 @@ namespace ArchiSteamFarm.JSON {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
internal sealed class NewDiscoveryQueueResponse {
|
internal sealed class NewDiscoveryQueueResponse {
|
||||||
@@ -380,7 +378,6 @@ namespace ArchiSteamFarm.JSON {
|
|||||||
// Deserialized from JSON
|
// Deserialized from JSON
|
||||||
private NewDiscoveryQueueResponse() { }
|
private NewDiscoveryQueueResponse() { }
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -31,53 +30,34 @@ using HtmlAgilityPack;
|
|||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class SteamSaleEvent : IDisposable {
|
internal sealed class SteamSaleEvent : IDisposable {
|
||||||
private static readonly DateTime SaleEndingDateUtc = new DateTime(2017, 1, 2, 18, 0, 0, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
private readonly Bot Bot;
|
private readonly Bot Bot;
|
||||||
private readonly Timer SteamAwardsTimer;
|
|
||||||
private readonly Timer SteamDiscoveryQueueTimer;
|
private readonly Timer SteamDiscoveryQueueTimer;
|
||||||
|
|
||||||
internal SteamSaleEvent(Bot bot) {
|
internal SteamSaleEvent(Bot bot) {
|
||||||
if (bot == null) {
|
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||||
throw new ArgumentNullException(nameof(bot));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bot = bot;
|
if (!Debugging.IsDebugBuild) {
|
||||||
|
|
||||||
if (DateTime.UtcNow >= SaleEndingDateUtc) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamAwardsTimer = new Timer(
|
|
||||||
async e => await VoteForSteamAwards().ConfigureAwait(false),
|
|
||||||
null,
|
|
||||||
TimeSpan.FromMinutes(1 + 0.2 * Bot.Bots.Count), // Delay
|
|
||||||
TimeSpan.FromHours(6.1) // Period
|
|
||||||
);
|
|
||||||
|
|
||||||
SteamDiscoveryQueueTimer = new Timer(
|
SteamDiscoveryQueueTimer = new Timer(
|
||||||
async e => await ExploreDiscoveryQueue().ConfigureAwait(false),
|
async e => await ExploreDiscoveryQueue().ConfigureAwait(false),
|
||||||
null,
|
null,
|
||||||
TimeSpan.FromMinutes(1 + 0.2 * Bot.Bots.Count), // Delay
|
TimeSpan.FromMinutes(1 + 0.2 * Bot.Bots.Count), // Delay
|
||||||
TimeSpan.FromHours(6.1) // Period
|
TimeSpan.FromHours(8.1) // Period
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
SteamAwardsTimer?.Dispose();
|
|
||||||
SteamDiscoveryQueueTimer?.Dispose();
|
SteamDiscoveryQueueTimer?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExploreDiscoveryQueue() {
|
private async Task ExploreDiscoveryQueue() {
|
||||||
if (DateTime.UtcNow >= SaleEndingDateUtc) {
|
if (!Bot.IsConnectedAndLoggedOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Bot.ArchiWebHandler.Ready) {
|
for (byte i = 0; (i < 3) && (await IsDiscoveryQueueAvailable().ConfigureAwait(false)).GetValueOrDefault(); i++) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (byte i = 0; (i < 3) && !(await IsDiscoveryQueueEmpty().ConfigureAwait(false)).GetValueOrDefault(); i++) {
|
|
||||||
HashSet<uint> queue = await Bot.ArchiWebHandler.GenerateNewDiscoveryQueue().ConfigureAwait(false);
|
HashSet<uint> queue = await Bot.ArchiWebHandler.GenerateNewDiscoveryQueue().ConfigureAwait(false);
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
break;
|
break;
|
||||||
@@ -95,11 +75,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool?> IsDiscoveryQueueEmpty() {
|
private async Task<bool?> IsDiscoveryQueueAvailable() {
|
||||||
if (!Bot.ArchiWebHandler.Ready) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetDiscoveryQueuePage().ConfigureAwait(false);
|
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetDiscoveryQueuePage().ConfigureAwait(false);
|
||||||
if (htmlDocument == null) {
|
if (htmlDocument == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -107,81 +83,18 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//div[@class='subtext']");
|
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//div[@class='subtext']");
|
||||||
if (htmlNode == null) {
|
if (htmlNode == null) {
|
||||||
// No cards for exploring the queue available
|
// Valid, no cards for exploring the queue available
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string text = htmlNode.InnerText;
|
string text = htmlNode.InnerText;
|
||||||
if (!string.IsNullOrEmpty(text)) {
|
if (!string.IsNullOrEmpty(text)) {
|
||||||
// It'd make more sense to check "Come back tomorrow", but it might not cover out-of-the-event queue
|
// 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);
|
return text.StartsWith("You can get ", StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(text));
|
Bot.ArchiLogger.LogNullError(nameof(text));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task VoteForSteamAwards() {
|
|
||||||
if (DateTime.UtcNow >= SaleEndingDateUtc) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Bot.ArchiWebHandler.Ready) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetSteamAwardsPage().ConfigureAwait(false);
|
|
||||||
|
|
||||||
HtmlNodeCollection nominationsNodes = htmlDocument?.DocumentNode.SelectNodes("//div[@class='vote_nominations store_horizontal_autoslider']");
|
|
||||||
if (nominationsNodes == null) {
|
|
||||||
// Event ended, error or likewise
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (HtmlNode nominationsNode in nominationsNodes) {
|
|
||||||
HtmlNode myVoteNode = nominationsNode.SelectSingleNode("./div[@class='vote_nomination your_vote']");
|
|
||||||
if (myVoteNode != null) {
|
|
||||||
// Already voted
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
string voteIDText = nominationsNode.GetAttributeValue("data-voteid", null);
|
|
||||||
if (string.IsNullOrEmpty(voteIDText)) {
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(voteIDText));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte voteID;
|
|
||||||
if (!byte.TryParse(voteIDText, out voteID) || (voteID == 0)) {
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(voteID));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlNodeCollection voteNodes = nominationsNode.SelectNodes("./div[@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 GabeN 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint appID;
|
|
||||||
if (!uint.TryParse(appIDText, out appID) || (appID == 0)) {
|
|
||||||
Bot.ArchiLogger.LogNullError(nameof(appID));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Bot.ArchiWebHandler.SteamAwardsVote(voteID, appID).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user