More bugs slained

This commit is contained in:
JustArchi
2015-10-28 21:47:31 +01:00
parent 03885babf6
commit 639067d04f
5 changed files with 19 additions and 9 deletions

View File

@@ -11,6 +11,7 @@
<AssemblyName>ArchiSteamFarm</AssemblyName> <AssemblyName>ArchiSteamFarm</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@@ -23,7 +24,6 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@@ -39,7 +39,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>none</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants> <DefineConstants>
@@ -47,6 +47,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"> <Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">

View File

@@ -62,7 +62,7 @@ namespace ArchiSteamFarm {
} }
internal void Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL) { internal void Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL) {
if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce) || string.IsNullOrEmpty(vanityURL)) { if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce)) {
return; return;
} }

View File

@@ -44,18 +44,21 @@ namespace ArchiSteamFarm {
// Find the number of badge pages // Find the number of badge pages
HtmlDocument badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(1).ConfigureAwait(false); HtmlDocument badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(1).ConfigureAwait(false);
if (badgesDocument == null) { if (badgesDocument == null) {
Logging.LogGenericWarning(Bot.BotName, "Could not get badges information, farming is stopped!");
return; return;
} }
var maxPages = 1; var maxPages = 1;
HtmlNodeCollection badgesPagesNodeCollection = badgesDocument.DocumentNode.SelectNodes("//a[@class='pagelink']"); HtmlNodeCollection badgesPagesNodeCollection = badgesDocument.DocumentNode.SelectNodes("//a[@class='pagelink']");
if (badgesPagesNodeCollection != null) { if (badgesPagesNodeCollection != null) {
maxPages = (byte) (badgesPagesNodeCollection.Count / 2 + 1); // Don't do this at home maxPages = (badgesPagesNodeCollection.Count / 2) + 1; // Don't do this at home
} }
// Find APPIDs we need to farm // Find APPIDs we need to farm
List<uint> appIDs = new List<uint>(); List<uint> appIDs = new List<uint>();
for (var page = 1; page <= maxPages; page++) { for (var page = 1; page <= maxPages; page++) {
Logging.LogGenericInfo(Bot.BotName, "Checking page: " + page + "/" + maxPages);
if (page > 1) { // Because we fetched page number 1 already if (page > 1) { // Because we fetched page number 1 already
badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(page).ConfigureAwait(false); badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(page).ConfigureAwait(false);
if (badgesDocument == null) { if (badgesDocument == null) {
@@ -71,14 +74,14 @@ namespace ArchiSteamFarm {
foreach (HtmlNode badgesPageNode in badgesPageNodes) { foreach (HtmlNode badgesPageNode in badgesPageNodes) {
string steamLink = badgesPageNode.GetAttributeValue("href", null); string steamLink = badgesPageNode.GetAttributeValue("href", null);
if (steamLink == null) { if (steamLink == null) {
page = maxPages; // Break from outer loop Logging.LogGenericWarning(Bot.BotName, "Couldn't get steamLink for one of the games: " + badgesPageNode.OuterHtml);
break; continue;
} }
uint appID = (uint) Utilities.OnlyNumbers(steamLink); uint appID = (uint) Utilities.OnlyNumbers(steamLink);
if (appID == 0) { if (appID == 0) {
page = maxPages; // Break from outer loop Logging.LogGenericWarning(Bot.BotName, "Couldn't get appID for one of the games: " + badgesPageNode.OuterHtml);
break; continue;
} }
appIDs.Add(appID); appIDs.Add(appID);

View File

@@ -23,6 +23,7 @@
*/ */
using System; using System;
using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
@@ -49,10 +50,12 @@ namespace ArchiSteamFarm {
Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message); Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message);
} }
[Conditional("DEBUG")]
internal static void LogGenericDebug(string botName, string message, [CallerMemberName] string previousMethodName = "") { internal static void LogGenericDebug(string botName, string message, [CallerMemberName] string previousMethodName = "") {
Log("[#] DEBUG: " + previousMethodName + "() <" + botName + "> " + message); Log("[#] DEBUG: " + previousMethodName + "() <" + botName + "> " + message);
} }
[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, [CallerMemberName] string previousMethodName = "") { internal static void LogGenericDebug(string message, [CallerMemberName] string previousMethodName = "") {
LogGenericDebug("DEBUG", message, previousMethodName); LogGenericDebug("DEBUG", message, previousMethodName);
} }

View File

@@ -37,6 +37,7 @@ namespace ArchiSteamFarm {
} }
internal void CheckTrades() { internal void CheckTrades() {
Logging.LogGenericDebug("");
if (ParsingTasks < 2) { if (ParsingTasks < 2) {
ParsingTasks++; ParsingTasks++;
Task.Run(() => ParseActiveTrades()); Task.Run(() => ParseActiveTrades());
@@ -87,7 +88,7 @@ namespace ArchiSteamFarm {
} }
if (!success) { if (!success) {
Logging.LogGenericWarning(Bot.BotName, "Response to trade " + tradeID + " failed!"); Logging.LogGenericWarning(Bot.BotName, "Response <accept: " + tradeAccepted + "> to trade " + tradeID + " failed!");
} }
if (tradeAccepted && success) { if (tradeAccepted && success) {