mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
I like my Steam account
This commit is contained in:
@@ -118,8 +118,8 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Bot.ArchiLogger.LogGenericDebug("Getting SteamAwards page...");
|
||||
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetSteamAwardsPage().ConfigureAwait(false);
|
||||
HtmlNode voteNode = htmlDocument?.DocumentNode.SelectSingleNode("//div[@class='vote_nomination ']");
|
||||
if (voteNode == null) {
|
||||
HtmlNodeCollection voteNodes = htmlDocument?.DocumentNode.SelectNodes("//div[@class='vote_nomination ']");
|
||||
if (voteNodes == null) {
|
||||
// Event ended, error or likewise
|
||||
Bot.ArchiLogger.LogGenericDebug("Could not get SteamAwards page, returning");
|
||||
return;
|
||||
@@ -150,6 +150,9 @@ namespace ArchiSteamFarm {
|
||||
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));
|
||||
|
||||
@@ -30,6 +30,8 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Utilities {
|
||||
private static readonly Random Random = new Random();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
||||
internal static void Forget(this object obj) { }
|
||||
@@ -54,5 +56,20 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static uint GetUnixTime() => (uint) DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user