mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Final family sharing bits
This commit is contained in:
@@ -38,9 +38,11 @@ using ArchiSteamFarm.JSON;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class ArchiWebHandler : IDisposable {
|
internal sealed class ArchiWebHandler : IDisposable {
|
||||||
private const string SteamCommunityHost = "steamcommunity.com";
|
private const string SteamCommunityHost = "steamcommunity.com";
|
||||||
|
private const string SteamStoreHost = "store.steampowered.com";
|
||||||
private const byte MinSessionTTL = GlobalConfig.DefaultHttpTimeout / 4; // Assume session is valid for at least that amount of seconds
|
private const byte MinSessionTTL = GlobalConfig.DefaultHttpTimeout / 4; // Assume session is valid for at least that amount of seconds
|
||||||
|
|
||||||
private static string SteamCommunityURL = "https://" + SteamCommunityHost;
|
private static string SteamCommunityURL = "https://" + SteamCommunityHost;
|
||||||
|
private static string SteamStoreURL = "https://" + SteamStoreHost;
|
||||||
private static int Timeout = GlobalConfig.DefaultHttpTimeout * 1000; // This must be int type
|
private static int Timeout = GlobalConfig.DefaultHttpTimeout * 1000; // This must be int type
|
||||||
|
|
||||||
private readonly Bot Bot;
|
private readonly Bot Bot;
|
||||||
@@ -55,6 +57,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal static void Init() {
|
internal static void Init() {
|
||||||
Timeout = Program.GlobalConfig.HttpTimeout * 1000;
|
Timeout = Program.GlobalConfig.HttpTimeout * 1000;
|
||||||
SteamCommunityURL = (Program.GlobalConfig.ForceHttp ? "http://" : "https://") + SteamCommunityHost;
|
SteamCommunityURL = (Program.GlobalConfig.ForceHttp ? "http://" : "https://") + SteamCommunityHost;
|
||||||
|
SteamStoreURL = (Program.GlobalConfig.ForceHttp ? "http://" : "https://") + SteamStoreHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static uint GetAppIDFromMarketHashName(string hashName) {
|
private static uint GetAppIDFromMarketHashName(string hashName) {
|
||||||
@@ -230,8 +233,13 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebBrowser.CookieContainer.Add(new Cookie("sessionid", sessionID, "/", "." + SteamCommunityHost));
|
WebBrowser.CookieContainer.Add(new Cookie("sessionid", sessionID, "/", "." + SteamCommunityHost));
|
||||||
|
WebBrowser.CookieContainer.Add(new Cookie("sessionid", sessionID, "/", "." + SteamStoreHost));
|
||||||
|
|
||||||
WebBrowser.CookieContainer.Add(new Cookie("steamLogin", steamLogin, "/", "." + SteamCommunityHost));
|
WebBrowser.CookieContainer.Add(new Cookie("steamLogin", steamLogin, "/", "." + SteamCommunityHost));
|
||||||
|
WebBrowser.CookieContainer.Add(new Cookie("steamLogin", steamLogin, "/", "." + SteamStoreHost));
|
||||||
|
|
||||||
WebBrowser.CookieContainer.Add(new Cookie("steamLoginSecure", steamLoginSecure, "/", "." + SteamCommunityHost));
|
WebBrowser.CookieContainer.Add(new Cookie("steamLoginSecure", steamLoginSecure, "/", "." + SteamCommunityHost));
|
||||||
|
WebBrowser.CookieContainer.Add(new Cookie("steamLoginSecure", steamLoginSecure, "/", "." + SteamStoreHost));
|
||||||
|
|
||||||
Logging.LogGenericInfo("Success!", Bot.BotName);
|
Logging.LogGenericInfo("Success!", Bot.BotName);
|
||||||
|
|
||||||
@@ -247,6 +255,41 @@ namespace ArchiSteamFarm {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal async Task<HashSet<ulong>> GetFamilySharingSteamIDs() {
|
||||||
|
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string request = SteamStoreURL + "/account/managedevices";
|
||||||
|
HtmlDocument htmlDocument = await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||||
|
|
||||||
|
HtmlNodeCollection htmlNodes = htmlDocument?.DocumentNode.SelectNodes("(//table[@class='accountTable'])[last()]//a/@data-miniprofile");
|
||||||
|
if (htmlNodes == null) {
|
||||||
|
return null; // OK, no authorized steamIDs
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<ulong> result = new HashSet<ulong>();
|
||||||
|
|
||||||
|
foreach (HtmlNode htmlNode in htmlNodes) {
|
||||||
|
string miniProfile = htmlNode.GetAttributeValue("data-miniprofile", null);
|
||||||
|
if (string.IsNullOrEmpty(miniProfile)) {
|
||||||
|
Logging.LogNullError(nameof(miniProfile), Bot.BotName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint steamID3;
|
||||||
|
if (!uint.TryParse(miniProfile, out steamID3) || steamID3 == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID3), Bot.BotName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong steamID = new SteamID(steamID3, EUniverse.Public, EAccountType.Individual);
|
||||||
|
result.Add(steamID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
internal async Task<bool> JoinGroup(ulong groupID) {
|
internal async Task<bool> JoinGroup(ulong groupID) {
|
||||||
if (groupID == 0) {
|
if (groupID == 0) {
|
||||||
Logging.LogNullError(nameof(groupID), Bot.BotName);
|
Logging.LogNullError(nameof(groupID), Bot.BotName);
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly CardsFarmer CardsFarmer;
|
private readonly CardsFarmer CardsFarmer;
|
||||||
|
|
||||||
private readonly ConcurrentHashSet<ulong> HandledGifts = new ConcurrentHashSet<ulong>();
|
private readonly ConcurrentHashSet<ulong> HandledGifts = new ConcurrentHashSet<ulong>();
|
||||||
|
private readonly ConcurrentHashSet<ulong> SteamFamilySharingIDs = new ConcurrentHashSet<ulong>();
|
||||||
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
||||||
private readonly SteamApps SteamApps;
|
private readonly SteamApps SteamApps;
|
||||||
private readonly SteamClient SteamClient;
|
private readonly SteamClient SteamClient;
|
||||||
@@ -279,6 +280,7 @@ namespace ArchiSteamFarm {
|
|||||||
CardsFarmer.Dispose();
|
CardsFarmer.Dispose();
|
||||||
HeartBeatTimer.Dispose();
|
HeartBeatTimer.Dispose();
|
||||||
HandledGifts.Dispose();
|
HandledGifts.Dispose();
|
||||||
|
SteamFamilySharingIDs.Dispose();
|
||||||
OwnedPackageIDs.Dispose();
|
OwnedPackageIDs.Dispose();
|
||||||
Trading.Dispose();
|
Trading.Dispose();
|
||||||
|
|
||||||
@@ -593,6 +595,18 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task InitializeFamilySharing() {
|
||||||
|
HashSet<ulong> steamIDs = await ArchiWebHandler.GetFamilySharingSteamIDs().ConfigureAwait(false);
|
||||||
|
if (steamIDs == null || steamIDs.Count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamFamilySharingIDs.ClearAndTrim();
|
||||||
|
foreach (ulong steamID in steamIDs) {
|
||||||
|
SteamFamilySharingIDs.Add(steamID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ImportAuthenticator(string maFilePath) {
|
private void ImportAuthenticator(string maFilePath) {
|
||||||
if ((BotDatabase.MobileAuthenticator != null) || !File.Exists(maFilePath)) {
|
if ((BotDatabase.MobileAuthenticator != null) || !File.Exists(maFilePath)) {
|
||||||
return;
|
return;
|
||||||
@@ -673,7 +687,7 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsMaster(steamID)) {
|
if (!IsMaster(steamID) && !SteamFamilySharingIDs.Contains(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2000,6 +2014,8 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeFamilySharing().Forget();
|
||||||
|
|
||||||
if (BotConfig.DismissInventoryNotifications) {
|
if (BotConfig.DismissInventoryNotifications) {
|
||||||
ArchiWebHandler.MarkInventory().Forget();
|
ArchiWebHandler.MarkInventory().Forget();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user