mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-15 22:10:30 +00:00
Slain some bugs
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,3 +1,11 @@
|
||||
#################
|
||||
## ArchiSteamFarm
|
||||
#################
|
||||
|
||||
# Ignore all config files, apart from example.xml
|
||||
ArchiSteamFarm/config/*
|
||||
!ArchiSteamFarm/config/example.xml
|
||||
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
@@ -53,7 +53,12 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal ArchiWebHandler(Bot bot, string apiKey) {
|
||||
Bot = bot;
|
||||
ApiKey = apiKey;
|
||||
|
||||
if (!string.IsNullOrEmpty(apiKey) && !apiKey.Equals("null")) {
|
||||
ApiKey = apiKey;
|
||||
} else {
|
||||
ApiKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL) {
|
||||
@@ -123,6 +128,10 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal List<SteamTradeOffer> GetTradeOffers() {
|
||||
if (ApiKey == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
KeyValue response;
|
||||
using (dynamic iEconService = WebAPI.GetInterface("IEconService")) {
|
||||
// Timeout
|
||||
@@ -212,6 +221,10 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal bool DeclineTradeOffer(ulong tradeID) {
|
||||
if (ApiKey == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tradeID == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,9 @@ namespace ArchiSteamFarm {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
if (SteamClient == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericWarning(BotName, "Disconnected from Steam, reconnecting...");
|
||||
Thread.Sleep(TimeSpan.FromMilliseconds(CallbackSleep));
|
||||
@@ -278,7 +281,12 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
case EResult.OK:
|
||||
Logging.LogGenericInfo(BotName, "Successfully logged on!");
|
||||
SteamFriends.SetPersonaName(SteamNickname);
|
||||
|
||||
string steamNickname = SteamNickname;
|
||||
if (!string.IsNullOrEmpty(steamNickname) && !steamNickname.Equals("null")) {
|
||||
SteamFriends.SetPersonaName(steamNickname);
|
||||
}
|
||||
|
||||
ArchiWebHandler.Init(SteamClient, callback.WebAPIUserNonce, callback.VanityURL);
|
||||
|
||||
ulong clanID = SteamMasterClanID;
|
||||
@@ -288,12 +296,17 @@ namespace ArchiSteamFarm {
|
||||
|
||||
await CardsFarmer.StartFarming().ConfigureAwait(false);
|
||||
break;
|
||||
default:
|
||||
case EResult.Timeout:
|
||||
case EResult.TryAnotherCM:
|
||||
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult + ", retrying...");
|
||||
Stop();
|
||||
Thread.Sleep(5000);
|
||||
Start();
|
||||
break;
|
||||
default:
|
||||
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult);
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async Task StartFarming() {
|
||||
Logging.LogGenericInfo(Bot.BotName, "Checking badges...");
|
||||
// Find the number of badge pages
|
||||
HtmlDocument badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(1).ConfigureAwait(false);
|
||||
if (badgesDocument == null) {
|
||||
@@ -64,7 +65,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
HtmlNodeCollection badgesPageNodes = badgesDocument.DocumentNode.SelectNodes("//a[@class='btn_green_white_innerfade btn_small_thin']");
|
||||
if (badgesPageNodes == null) {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (HtmlNode badgesPageNode in badgesPageNodes) {
|
||||
@@ -86,6 +87,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// Start farming
|
||||
while (appIDs.Count > 0) {
|
||||
Logging.LogGenericInfo(Bot.BotName, "Farming in progress...");
|
||||
uint appID = appIDs[0];
|
||||
if (await Farm(appID).ConfigureAwait(false)) {
|
||||
appIDs.Remove(appID);
|
||||
@@ -93,6 +95,8 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo(Bot.BotName, "Farming finished!");
|
||||
}
|
||||
|
||||
private async Task<bool?> ShouldFarm(ulong appID) {
|
||||
@@ -119,6 +123,7 @@ namespace ArchiSteamFarm {
|
||||
while (keepFarming == null || keepFarming.Value) {
|
||||
if (!NowFarming) {
|
||||
NowFarming = true;
|
||||
Logging.LogGenericInfo(Bot.BotName, "Now farming: " + appID);
|
||||
Bot.PlayGame(appID);
|
||||
}
|
||||
if (AutoResetEvent.WaitOne(1000 * 60 * StatusCheckSleep)) {
|
||||
@@ -128,6 +133,7 @@ namespace ArchiSteamFarm {
|
||||
keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo(Bot.BotName, "Stopped farming: " + appID);
|
||||
Bot.PlayGame(0);
|
||||
NowFarming = false;
|
||||
return success;
|
||||
|
||||
@@ -28,7 +28,9 @@ using System.Runtime.CompilerServices;
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Logging {
|
||||
private static void Log(string message) {
|
||||
Console.WriteLine(DateTime.Now + " " + message);
|
||||
lock (Program.ConsoleLock) {
|
||||
Console.WriteLine(DateTime.Now + " " + message);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogGenericError(string botName, string message, [CallerMemberName] string previousMethodName = "") {
|
||||
|
||||
@@ -39,14 +39,16 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static string GetSteamGuardCode(string botLogin, bool twoFactorAuthentication) {
|
||||
string result;
|
||||
lock (ConsoleLock) {
|
||||
if (twoFactorAuthentication) {
|
||||
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
||||
} else {
|
||||
Console.Write("<" + botLogin + "> Please enter the auth code sent to your email : ");
|
||||
}
|
||||
return Console.ReadLine();
|
||||
result = Console.ReadLine();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void ShutdownAllBots() {
|
||||
|
||||
@@ -3,14 +3,25 @@
|
||||
|
||||
<!-- Every bot should have it's own unique .xml configuration file, this is example on which you can base on -->
|
||||
|
||||
<Enabled value="true"/> <!-- Master switch to turn account on and off -->
|
||||
<!-- Master switch to turn account on and off, set to "true" after you're done -->
|
||||
<Enabled type="bool" value="false"/>
|
||||
|
||||
<!-- Steam -->
|
||||
<SteamLogin value="Foo"/> <!-- This is your steam login, the one you use for logging in to steam -->
|
||||
<SteamPassword value="Bar"/> <!-- This is your steam password, the one you use for logging in to steam -->
|
||||
<SteamNickname value="ArchiSteamFarmer"/> <!-- This is your steam nickname, the one you want to use for bot. Can be anything up to 32 characters -->
|
||||
<SteamApiKey value="FFFFFFFF"/> <!-- Get one at https://steamcommunity.com/dev/apikey -->
|
||||
<SteamMasterID value="76561198006963719"/> <!-- This is steamID of the master, aka the "root" user being able to execute any command -->
|
||||
<SteamMasterClanID value="0"/> <!-- If you want from the bot to join particular chat of given clan, set it here, otherwise leave at 0 -->
|
||||
<!-- This is your steam login, the one you use for logging in to steam -->
|
||||
<SteamLogin type="string" value="Foo"/>
|
||||
|
||||
</configuration>
|
||||
<!-- This is your steam password, the one you use for logging in to steam -->
|
||||
<SteamPassword type="string" value="Bar"/>
|
||||
|
||||
<!-- This is steam nickname, the one you want to use for bot. Can be anything up to 32 characters -->
|
||||
<SteamNickname type="string" value="null"/>
|
||||
|
||||
<!-- Get one at https://steamcommunity.com/dev/apikey while logged in as bot, domain doesn't matter. You can also use "null", but that will disable many API functions, e.g. trading -->
|
||||
<SteamApiKey type="string" value="null"/>
|
||||
|
||||
<!-- This is steamID of the bot-master - you, in steamID64 format -->
|
||||
<SteamMasterID type="ulong" value="76561198006963719"/>
|
||||
|
||||
<!-- If you want from the bot to join particular chat of given clan, set it here, otherwise leave at 0 -->
|
||||
<SteamMasterClanID type="ulong" value="0"/>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user