Compare commits

..

8 Commits

Author SHA1 Message Date
JustArchi
3d19a69c60 Let's hope this is the last one 2016-06-20 13:51:17 +02:00
JustArchi
f6a8d16c85 More fixes 2016-06-20 13:45:12 +02:00
JustArchi
f13991c2da Bump... 2016-06-20 13:26:43 +02:00
JustArchi
40a3d6558d GabeN broke more than I thought 2016-06-20 13:26:30 +02:00
JustArchi
fea76a3dda Derp 2016-06-20 13:18:06 +02:00
JustArchi
1087c01a2c And don't you dare to break again 2016-06-20 13:15:35 +02:00
JustArchi
fd49ff5483 Thanks GabeN 2016-06-20 13:09:27 +02:00
JustArchi
0f5d9a665c Bump 2016-06-20 13:01:42 +02:00
5 changed files with 50 additions and 11 deletions

View File

@@ -47,6 +47,8 @@ namespace ArchiSteamFarm {
private readonly SemaphoreSlim SessionSemaphore = new SemaphoreSlim(1);
private readonly WebBrowser WebBrowser;
internal bool Ready { get; private set; }
private ulong SteamID;
private DateTime LastSessionRefreshCheck = DateTime.MinValue;
@@ -117,7 +119,9 @@ namespace ArchiSteamFarm {
WebBrowser = new WebBrowser(bot.BotName);
}
internal bool Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) {
internal void OnDisconnected() => Ready = false;
internal async Task<bool> Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) {
if ((steamClient == null) || string.IsNullOrEmpty(webAPIUserNonce)) {
Logging.LogNullError(nameof(steamClient) + " || " + nameof(webAPIUserNonce), Bot.BotName);
return false;
@@ -179,10 +183,17 @@ namespace ArchiSteamFarm {
string steamLoginSecure = authResult["tokensecure"].Value;
WebBrowser.CookieContainer.Add(new Cookie("steamLoginSecure", steamLoginSecure, "/", "." + SteamCommunityHost));
if (!UnlockParentalAccount(parentalPin).Result) {
// Apparently Steam is too stupid to detect language from our headers, so we must ask for it explicitly
if (!await SetLanguage().ConfigureAwait(false)) {
return false;
}
// Unlock Steam Parental if needed
if (!await UnlockParentalAccount(parentalPin).ConfigureAwait(false)) {
return false;
}
Ready = true;
LastSessionRefreshCheck = DateTime.Now;
return true;
}
@@ -246,7 +257,7 @@ namespace ArchiSteamFarm {
return null;
}
string request = SteamCommunityURL + "/mobileconf/conf?p=" + deviceID + "&a=" + SteamID + "&k=" + WebUtility.UrlEncode(confirmationHash) + "&t=" + time + "&m=android&tag=conf";
string request = SteamCommunityURL + "/mobileconf/conf?l=english&p=" + deviceID + "&a=" + SteamID + "&k=" + WebUtility.UrlEncode(confirmationHash) + "&t=" + time + "&m=android&tag=conf";
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
}
@@ -435,7 +446,7 @@ namespace ArchiSteamFarm {
return null;
}
string request = SteamCommunityURL + "/tradeoffer/" + tradeID;
string request = SteamCommunityURL + "/tradeoffer/" + tradeID + "?l=english";
HtmlDocument htmlDocument = await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
if (htmlDocument == null) {
@@ -837,7 +848,7 @@ namespace ArchiSteamFarm {
return null;
}
string request = SteamCommunityURL + "/my/badges?p=" + page;
string request = SteamCommunityURL + "/my/badges?l=english&p=" + page;
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
}
@@ -852,7 +863,7 @@ namespace ArchiSteamFarm {
return null;
}
string request = SteamCommunityURL + "/my/gamecards/" + appID;
string request = SteamCommunityURL + "/my/gamecards/" + appID + "?l=english";
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
}
@@ -933,5 +944,21 @@ namespace ArchiSteamFarm {
Logging.LogGenericInfo("Success!", Bot.BotName);
return true;
}
private async Task<bool> SetLanguage() {
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
if (string.IsNullOrEmpty(sessionID)) {
Logging.LogNullError(nameof(sessionID), Bot.BotName);
return false;
}
string request = SteamCommunityURL + "/actions/SetLanguage";
Dictionary<string, string> data = new Dictionary<string, string>(2) {
{ "sessionid", sessionID },
{ "language", "english" }
};
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
}
}
}

View File

@@ -306,7 +306,7 @@ namespace ArchiSteamFarm {
return false;
}
if (ArchiWebHandler.Init(SteamClient, callback.Nonce, BotConfig.SteamParentalPIN)) {
if (await ArchiWebHandler.Init(SteamClient, callback.Nonce, BotConfig.SteamParentalPIN).ConfigureAwait(false)) {
return true;
}
@@ -1452,6 +1452,7 @@ namespace ArchiSteamFarm {
return;
}
ArchiWebHandler.OnDisconnected();
Logging.LogGenericInfo("Disconnected from Steam!", BotName);
FirstTradeSent = false;
@@ -1503,6 +1504,14 @@ namespace ArchiSteamFarm {
return;
}
for (byte i = 0; (i < Program.GlobalConfig.HttpTimeout) && !ArchiWebHandler.Ready; i++) {
await Task.Delay(1000).ConfigureAwait(false);
}
if (!ArchiWebHandler.Ready) {
return;
}
bool acceptedSomething = false;
foreach (ulong gid in callback.GuestPasses.Select(guestPass => guestPass["gid"].AsUnsignedLong()).Where(gid => gid != 0)) {
Logging.LogGenericInfo("Accepting gift: " + gid + "...", BotName);
@@ -1698,7 +1707,7 @@ namespace ArchiSteamFarm {
}
}
if (!ArchiWebHandler.Init(SteamClient, callback.WebAPIUserNonce, BotConfig.SteamParentalPIN)) {
if (!await ArchiWebHandler.Init(SteamClient, callback.WebAPIUserNonce, BotConfig.SteamParentalPIN).ConfigureAwait(false)) {
if (!await RefreshSession().ConfigureAwait(false)) {
return;
}

View File

@@ -389,7 +389,7 @@ namespace ArchiSteamFarm {
}
Logging.LogGenericInfo("Status for " + appID + ": " + progress, Bot.BotName);
return progress.Equals("No card drops remaining");
return !progress.Equals("No card drops remaining");
}
private bool FarmMultiple() {

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.2")]
[assembly: AssemblyFileVersion("2.1.0.2")]
[assembly: AssemblyVersion("2.1.0.4")]
[assembly: AssemblyFileVersion("2.1.0.4")]

View File

@@ -80,6 +80,9 @@ namespace ArchiSteamFarm {
// Most web services expect that UserAgent is set, so we declare it globally
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(DefaultUserAgent);
// We should always operate in English language, declare it globally
HttpClient.DefaultRequestHeaders.AcceptLanguage.ParseAdd("en-US,en;q=0.8,en-GB;q=0.6");
}
internal async Task<bool> UrlHeadRetry(string request, string referer = null) {