mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 15:00:29 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7587ff024c | ||
|
|
06778c9bb0 | ||
|
|
7a97045412 | ||
|
|
5d9bedfd28 | ||
|
|
575992c25d | ||
|
|
72db5bc9f3 | ||
|
|
b015720a3e | ||
|
|
84a6d4501b | ||
|
|
07049e71c0 | ||
|
|
4710d9c1eb | ||
|
|
d08462745a | ||
|
|
eb4e9ee077 | ||
|
|
601a486b13 | ||
|
|
14867f470d | ||
|
|
187f0800b2 | ||
|
|
3afa202d0b | ||
|
|
d33e76c8b0 | ||
|
|
3061c55eaf | ||
|
|
621a1dc2cb | ||
|
|
1a832780a2 | ||
|
|
ab531c80df | ||
|
|
f20ea0a87f | ||
|
|
3e7f726afb |
@@ -34,6 +34,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class ArchiWebHandler {
|
internal sealed class ArchiWebHandler {
|
||||||
|
private const string SteamCommunity = "steamcommunity.com";
|
||||||
|
|
||||||
|
private static string SteamCommunityURL = "https://" + SteamCommunity;
|
||||||
|
|
||||||
private static int Timeout = 30 * 1000;
|
private static int Timeout = 30 * 1000;
|
||||||
|
|
||||||
private readonly Bot Bot;
|
private readonly Bot Bot;
|
||||||
@@ -43,9 +47,14 @@ 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://") + SteamCommunity;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ArchiWebHandler(Bot bot) {
|
internal ArchiWebHandler(Bot bot) {
|
||||||
|
if (bot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bot = bot;
|
Bot = bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +96,7 @@ namespace ArchiSteamFarm {
|
|||||||
sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)),
|
sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)),
|
||||||
encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)),
|
encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)),
|
||||||
method: WebRequestMethods.Http.Post,
|
method: WebRequestMethods.Http.Post,
|
||||||
secure: true
|
secure: !Program.GlobalConfig.ForceHttp
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.LogGenericException(e, Bot.BotName);
|
Logging.LogGenericException(e, Bot.BotName);
|
||||||
@@ -122,7 +131,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HtmlDocument htmlDocument = null;
|
HtmlDocument htmlDocument = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
||||||
htmlDocument = await WebBrowser.UrlGetToHtmlDocument("https://steamcommunity.com/my/profile", Cookie).ConfigureAwait(false);
|
htmlDocument = await WebBrowser.UrlGetToHtmlDocument(SteamCommunityURL + "/my/profile", Cookie).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htmlDocument == null) {
|
if (htmlDocument == null) {
|
||||||
@@ -159,7 +168,7 @@ namespace ArchiSteamFarm {
|
|||||||
response = iEconService.GetTradeOffers(
|
response = iEconService.GetTradeOffers(
|
||||||
get_received_offers: 1,
|
get_received_offers: 1,
|
||||||
active_only: 1,
|
active_only: 1,
|
||||||
secure: true
|
secure: !Program.GlobalConfig.ForceHttp
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.LogGenericException(e, Bot.BotName);
|
Logging.LogGenericException(e, Bot.BotName);
|
||||||
@@ -176,7 +185,7 @@ namespace ArchiSteamFarm {
|
|||||||
foreach (KeyValue trade in response["trade_offers_received"].Children) {
|
foreach (KeyValue trade in response["trade_offers_received"].Children) {
|
||||||
Steam.TradeOffer tradeOffer = new Steam.TradeOffer {
|
Steam.TradeOffer tradeOffer = new Steam.TradeOffer {
|
||||||
tradeofferid = trade["tradeofferid"].AsString(),
|
tradeofferid = trade["tradeofferid"].AsString(),
|
||||||
accountid_other = trade["accountid_other"].AsInteger(),
|
accountid_other = (uint) trade["accountid_other"].AsUnsignedLong(), // TODO: Correct this when SK2 with https://github.com/SteamRE/SteamKit/pull/255 gets released
|
||||||
trade_offer_state = trade["trade_offer_state"].AsEnum<Steam.TradeOffer.ETradeOfferState>()
|
trade_offer_state = trade["trade_offer_state"].AsEnum<Steam.TradeOffer.ETradeOfferState>()
|
||||||
};
|
};
|
||||||
foreach (KeyValue item in trade["items_to_give"].Children) {
|
foreach (KeyValue item in trade["items_to_give"].Children) {
|
||||||
@@ -215,7 +224,7 @@ namespace ArchiSteamFarm {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string request = "https://steamcommunity.com/gid/" + clanID;
|
string request = SteamCommunityURL + "/gid/" + clanID;
|
||||||
|
|
||||||
Dictionary<string, string> data = new Dictionary<string, string>(2) {
|
Dictionary<string, string> data = new Dictionary<string, string>(2) {
|
||||||
{"sessionID", sessionID},
|
{"sessionID", sessionID},
|
||||||
@@ -245,7 +254,7 @@ namespace ArchiSteamFarm {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string referer = "https://steamcommunity.com/tradeoffer/" + tradeID;
|
string referer = SteamCommunityURL + "/tradeoffer/" + tradeID;
|
||||||
string request = referer + "/accept";
|
string request = referer + "/accept";
|
||||||
|
|
||||||
Dictionary<string, string> data = new Dictionary<string, string>(3) {
|
Dictionary<string, string> data = new Dictionary<string, string>(3) {
|
||||||
@@ -281,7 +290,7 @@ namespace ArchiSteamFarm {
|
|||||||
response = iEconService.DeclineTradeOffer(
|
response = iEconService.DeclineTradeOffer(
|
||||||
tradeofferid: tradeID.ToString(),
|
tradeofferid: tradeID.ToString(),
|
||||||
method: WebRequestMethods.Http.Post,
|
method: WebRequestMethods.Http.Post,
|
||||||
secure: true
|
secure: !Program.GlobalConfig.ForceHttp
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.LogGenericException(e, Bot.BotName);
|
Logging.LogGenericException(e, Bot.BotName);
|
||||||
@@ -300,7 +309,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal async Task<List<Steam.Item>> GetMyTradableInventory() {
|
internal async Task<List<Steam.Item>> GetMyTradableInventory() {
|
||||||
JObject jObject = null;
|
JObject jObject = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && jObject == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && jObject == null; i++) {
|
||||||
jObject = await WebBrowser.UrlGetToJObject("https://steamcommunity.com/my/inventory/json/753/6?trading=1", Cookie).ConfigureAwait(false);
|
jObject = await WebBrowser.UrlGetToJObject(SteamCommunityURL + "/my/inventory/json/753/6?trading=1", Cookie).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jObject == null) {
|
if (jObject == null) {
|
||||||
@@ -358,7 +367,7 @@ namespace ArchiSteamFarm {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
string referer = "https://steamcommunity.com/tradeoffer/new";
|
string referer = SteamCommunityURL + "/tradeoffer/new";
|
||||||
string request = referer + "/send";
|
string request = referer + "/send";
|
||||||
|
|
||||||
foreach (Steam.TradeOfferRequest trade in trades) {
|
foreach (Steam.TradeOfferRequest trade in trades) {
|
||||||
@@ -392,7 +401,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HtmlDocument htmlDocument = null;
|
HtmlDocument htmlDocument = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
||||||
htmlDocument = await WebBrowser.UrlGetToHtmlDocument("https://steamcommunity.com/profiles/" + SteamID + "/badges?l=english&p=" + page, Cookie).ConfigureAwait(false);
|
htmlDocument = await WebBrowser.UrlGetToHtmlDocument(SteamCommunityURL + "/profiles/" + SteamID + "/badges?l=english&p=" + page, Cookie).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htmlDocument == null) {
|
if (htmlDocument == null) {
|
||||||
@@ -410,7 +419,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HtmlDocument htmlDocument = null;
|
HtmlDocument htmlDocument = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && htmlDocument == null; i++) {
|
||||||
htmlDocument = await WebBrowser.UrlGetToHtmlDocument("https://steamcommunity.com/profiles/" + SteamID + "/gamecards/" + appID + "?l=english", Cookie).ConfigureAwait(false);
|
htmlDocument = await WebBrowser.UrlGetToHtmlDocument(SteamCommunityURL + "/profiles/" + SteamID + "/gamecards/" + appID + "?l=english", Cookie).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htmlDocument == null) {
|
if (htmlDocument == null) {
|
||||||
@@ -428,7 +437,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
|
||||||
response = await WebBrowser.UrlGet("https://steamcommunity.com/profiles/" + SteamID + "/inventory", Cookie).ConfigureAwait(false);
|
response = await WebBrowser.UrlGet(SteamCommunityURL + "/profiles/" + SteamID + "/inventory", Cookie).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
@@ -449,9 +458,12 @@ namespace ArchiSteamFarm {
|
|||||||
{ "pin", parentalPin }
|
{ "pin", parentalPin }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string referer = SteamCommunityURL;
|
||||||
|
string request = referer + "/parental/ajaxunlock";
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
|
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
|
||||||
response = await WebBrowser.UrlPost("https://steamcommunity.com/parental/ajaxunlock", data, Cookie, "https://steamcommunity.com/").ConfigureAwait(false);
|
response = await WebBrowser.UrlPost(request, data, Cookie, referer).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
|
|||||||
@@ -172,26 +172,16 @@ namespace ArchiSteamFarm {
|
|||||||
SentryFile = botPath + ".bin";
|
SentryFile = botPath + ".bin";
|
||||||
|
|
||||||
// Support and convert SDA files
|
// Support and convert SDA files
|
||||||
if (BotDatabase.SteamGuardAccount == null && File.Exists(botPath + ".maFile")) {
|
string maFilePath = botPath + ".maFile";
|
||||||
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", botName);
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
||||||
try {
|
ImportAuthenticator(maFilePath);
|
||||||
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(botPath + ".maFile"));
|
|
||||||
File.Delete(botPath + ".maFile");
|
|
||||||
Logging.LogGenericInfo("Success!", botName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logging.LogGenericException(e, botName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
SteamClient = new SteamClient();
|
SteamClient = new SteamClient();
|
||||||
|
|
||||||
if (Program.GlobalConfig.Debug && !Debugging.NetHookAlreadyInitialized) {
|
if (Program.GlobalConfig.Debug && !Debugging.NetHookAlreadyInitialized && Directory.Exists(Program.DebugDirectory)) {
|
||||||
try {
|
try {
|
||||||
if (Directory.Exists(Program.DebugDirectory)) {
|
|
||||||
Directory.Delete(Program.DebugDirectory, true);
|
|
||||||
}
|
|
||||||
Directory.CreateDirectory(Program.DebugDirectory);
|
|
||||||
SteamClient.DebugNetworkListener = new NetHookNetworkListener(Program.DebugDirectory);
|
SteamClient.DebugNetworkListener = new NetHookNetworkListener(Program.DebugDirectory);
|
||||||
Debugging.NetHookAlreadyInitialized = true;
|
Debugging.NetHookAlreadyInitialized = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -262,16 +252,16 @@ namespace ArchiSteamFarm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
|
|
||||||
if (confirmations == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
|
||||||
|
if (confirmations == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Confirmation confirmation in confirmations) {
|
foreach (Confirmation confirmation in confirmations) {
|
||||||
if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) {
|
if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) {
|
||||||
Logging.LogGenericInfo("Accepting confirmation: Success!", BotName);
|
Logging.LogGenericInfo("Accepting confirmation: Success!", BotName);
|
||||||
@@ -283,6 +273,9 @@ namespace ArchiSteamFarm {
|
|||||||
Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName);
|
Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName);
|
||||||
Logging.LogGenericWarning("Confirmation could not be accepted because of invalid token exception", BotName);
|
Logging.LogGenericWarning("Confirmation could not be accepted because of invalid token exception", BotName);
|
||||||
Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName);
|
Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logging.LogGenericException(e, BotName);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +288,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal async Task Restart() {
|
internal async Task Restart() {
|
||||||
Stop();
|
await Stop().ConfigureAwait(false);
|
||||||
await Utilities.SleepAsync(500).ConfigureAwait(false);
|
|
||||||
await Start().ConfigureAwait(false);
|
await Start().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +297,7 @@ namespace ArchiSteamFarm {
|
|||||||
await ResponseSendTrade().ConfigureAwait(false);
|
await ResponseSendTrade().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
if (BotConfig.ShutdownOnFarmingFinished) {
|
if (BotConfig.ShutdownOnFarmingFinished) {
|
||||||
Shutdown();
|
await Shutdown().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +321,10 @@ namespace ArchiSteamFarm {
|
|||||||
case "!exit":
|
case "!exit":
|
||||||
Program.Exit();
|
Program.Exit();
|
||||||
return null;
|
return null;
|
||||||
|
case "!farm":
|
||||||
|
return await ResponseFarm().ConfigureAwait(false);
|
||||||
|
case "!loot":
|
||||||
|
return await ResponseSendTrade().ConfigureAwait(false);
|
||||||
case "!rejoinchat":
|
case "!rejoinchat":
|
||||||
return ResponseRejoinChat();
|
return ResponseRejoinChat();
|
||||||
case "!restart":
|
case "!restart":
|
||||||
@@ -339,9 +335,10 @@ namespace ArchiSteamFarm {
|
|||||||
case "!statusall":
|
case "!statusall":
|
||||||
return ResponseStatusAll();
|
return ResponseStatusAll();
|
||||||
case "!stop":
|
case "!stop":
|
||||||
return ResponseStop();
|
return await ResponseStop().ConfigureAwait(false);
|
||||||
case "!loot":
|
case "!update":
|
||||||
return await ResponseSendTrade().ConfigureAwait(false);
|
await Program.CheckForUpdate().ConfigureAwait(false);
|
||||||
|
return "Done!";
|
||||||
default:
|
default:
|
||||||
return "Unrecognized command: " + message;
|
return "Unrecognized command: " + message;
|
||||||
}
|
}
|
||||||
@@ -360,6 +357,10 @@ namespace ArchiSteamFarm {
|
|||||||
} else {
|
} else {
|
||||||
return await ResponseAddLicense(BotName, args[1]).ConfigureAwait(false);
|
return await ResponseAddLicense(BotName, args[1]).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
case "!farm":
|
||||||
|
return await ResponseFarm(args[1]).ConfigureAwait(false);
|
||||||
|
case "!loot":
|
||||||
|
return await ResponseSendTrade(args[1]).ConfigureAwait(false);
|
||||||
case "!play":
|
case "!play":
|
||||||
if (args.Length > 2) {
|
if (args.Length > 2) {
|
||||||
return await ResponsePlay(args[1], args[2]).ConfigureAwait(false);
|
return await ResponsePlay(args[1], args[2]).ConfigureAwait(false);
|
||||||
@@ -374,12 +375,10 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
case "!start":
|
case "!start":
|
||||||
return await ResponseStart(args[1]).ConfigureAwait(false);
|
return await ResponseStart(args[1]).ConfigureAwait(false);
|
||||||
case "!stop":
|
|
||||||
return ResponseStop(args[1]);
|
|
||||||
case "!status":
|
case "!status":
|
||||||
return ResponseStatus(args[1]);
|
return ResponseStatus(args[1]);
|
||||||
case "!loot":
|
case "!stop":
|
||||||
return await ResponseSendTrade(args[1]).ConfigureAwait(false);
|
return await ResponseStop(args[1]).ConfigureAwait(false);
|
||||||
default:
|
default:
|
||||||
return "Unrecognized command: " + args[0];
|
return "Unrecognized command: " + args[0];
|
||||||
}
|
}
|
||||||
@@ -406,22 +405,87 @@ namespace ArchiSteamFarm {
|
|||||||
SteamClient.Connect();
|
SteamClient.Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Stop() {
|
private async Task Stop() {
|
||||||
if (!SteamClient.IsConnected) {
|
if (!SteamClient.IsConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging.LogGenericInfo("Stopping...", BotName);
|
Logging.LogGenericInfo("Stopping...", BotName);
|
||||||
|
|
||||||
SteamClient.Disconnect();
|
for (byte i = 0; i < WebBrowser.MaxRetries && SteamClient.IsConnected; i++) {
|
||||||
|
SteamClient.Disconnect();
|
||||||
|
await Utilities.SleepAsync(1000).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SteamClient.IsConnected) {
|
||||||
|
Logging.LogGenericWarning("Could not stop this bot instance!", BotName);
|
||||||
|
} else {
|
||||||
|
Logging.LogGenericInfo("Stopped!", BotName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Shutdown() {
|
private async Task Shutdown() {
|
||||||
KeepRunning = false;
|
KeepRunning = false;
|
||||||
Stop();
|
await Stop().ConfigureAwait(false);
|
||||||
Program.OnBotShutdown();
|
Program.OnBotShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ImportAuthenticator(string maFilePath) {
|
||||||
|
if (BotDatabase.SteamGuardAccount != null || !File.Exists(maFilePath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
||||||
|
try {
|
||||||
|
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
||||||
|
File.Delete(maFilePath);
|
||||||
|
Logging.LogGenericInfo("Success!", BotName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logging.LogGenericException(e, BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is SDA file, then we should already have everything ready
|
||||||
|
if (BotDatabase.SteamGuardAccount.Session != null) {
|
||||||
|
Logging.LogGenericInfo("Successfully finished importing mobile authenticator!", BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// But here we're dealing with WinAuth authenticator
|
||||||
|
Logging.LogGenericInfo("ASF requires a few more steps to complete authenticator import...", BotName);
|
||||||
|
|
||||||
|
InitializeLoginAndPassword();
|
||||||
|
|
||||||
|
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
||||||
|
LoginResult loginResult;
|
||||||
|
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
||||||
|
switch (loginResult) {
|
||||||
|
case LoginResult.Need2FA:
|
||||||
|
userLogin.TwoFactorCode = Program.GetUserInput(BotName, Program.EUserInputType.TwoFactorAuthentication);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logging.LogGenericError("Unhandled situation: " + loginResult, BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userLogin.Session == null) {
|
||||||
|
BotDatabase.SteamGuardAccount = null;
|
||||||
|
Logging.LogGenericError("Session is invalid, linking can't be completed!", BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BotDatabase.SteamGuardAccount.FullyEnrolled = true;
|
||||||
|
BotDatabase.SteamGuardAccount.Session = userLogin.Session;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(BotDatabase.SteamGuardAccount.DeviceID)) {
|
||||||
|
BotDatabase.SteamGuardAccount.DeviceID = Program.GetUserInput(BotName, Program.EUserInputType.DeviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
BotDatabase.Save();
|
||||||
|
Logging.LogGenericInfo("Successfully finished importing mobile authenticator!", BotName);
|
||||||
|
}
|
||||||
|
|
||||||
private string ResponseStatus() {
|
private string ResponseStatus() {
|
||||||
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
|
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
|
||||||
return "Bot " + BotName + " is currently farming appIDs: " + string.Join(", ", CardsFarmer.CurrentGamesFarming) + " and has a total of " + CardsFarmer.GamesToFarm.Count + " games left to farm.";
|
return "Bot " + BotName + " is currently farming appIDs: " + string.Join(", ", CardsFarmer.CurrentGamesFarming) + " and has a total of " + CardsFarmer.GamesToFarm.Count + " games left to farm.";
|
||||||
@@ -562,6 +626,24 @@ namespace ArchiSteamFarm {
|
|||||||
return await bot.Response2FAOK().ConfigureAwait(false);
|
return await bot.Response2FAOK().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> ResponseFarm() {
|
||||||
|
await CardsFarmer.RestartFarming().ConfigureAwait(false);
|
||||||
|
return "Done!";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<string> ResponseFarm(string botName) {
|
||||||
|
if (string.IsNullOrEmpty(botName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bot bot;
|
||||||
|
if (!Bots.TryGetValue(botName, out bot)) {
|
||||||
|
return "Couldn't find any bot named " + botName + "!";
|
||||||
|
}
|
||||||
|
|
||||||
|
return await bot.ResponseFarm().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseRedeem(string message, bool validate) {
|
private async Task<string> ResponseRedeem(string message, bool validate) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -840,16 +922,16 @@ namespace ArchiSteamFarm {
|
|||||||
return await bot.ResponseStart().ConfigureAwait(false);
|
return await bot.ResponseStart().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseStop() {
|
private async Task<string> ResponseStop() {
|
||||||
if (!KeepRunning) {
|
if (!KeepRunning) {
|
||||||
return "That bot instance is already inactive!";
|
return "That bot instance is already inactive!";
|
||||||
}
|
}
|
||||||
|
|
||||||
Shutdown();
|
await Shutdown().ConfigureAwait(false);
|
||||||
return "Done!";
|
return "Done!";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResponseStop(string botName) {
|
private static async Task<string> ResponseStop(string botName) {
|
||||||
if (string.IsNullOrEmpty(botName)) {
|
if (string.IsNullOrEmpty(botName)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -859,7 +941,7 @@ namespace ArchiSteamFarm {
|
|||||||
return "Couldn't find any bot named " + botName + "!";
|
return "Couldn't find any bot named " + botName + "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return bot.ResponseStop();
|
return await bot.ResponseStop().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCallbacks() {
|
private void HandleCallbacks() {
|
||||||
@@ -895,6 +977,9 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
||||||
|
|
||||||
|
InitializeLoginAndPassword();
|
||||||
|
|
||||||
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
||||||
LoginResult loginResult;
|
LoginResult loginResult;
|
||||||
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
||||||
@@ -957,6 +1042,16 @@ namespace ArchiSteamFarm {
|
|||||||
SteamFriends.JoinChat(BotConfig.SteamMasterClanID);
|
SteamFriends.JoinChat(BotConfig.SteamMasterClanID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializeLoginAndPassword() {
|
||||||
|
if (string.IsNullOrEmpty(BotConfig.SteamLogin)) {
|
||||||
|
BotConfig.SteamLogin = Program.GetUserInput(BotName, Program.EUserInputType.Login);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(BotConfig.SteamPassword) && string.IsNullOrEmpty(BotDatabase.LoginKey)) {
|
||||||
|
BotConfig.SteamPassword = Program.GetUserInput(BotName, Program.EUserInputType.Password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
return;
|
return;
|
||||||
@@ -985,13 +1080,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BotConfig.SteamLogin)) {
|
InitializeLoginAndPassword();
|
||||||
BotConfig.SteamLogin = Program.GetUserInput(BotName, Program.EUserInputType.Login);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BotConfig.SteamPassword) && string.IsNullOrEmpty(BotDatabase.LoginKey)) {
|
|
||||||
BotConfig.SteamPassword = Program.GetUserInput(BotName, Program.EUserInputType.Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
||||||
Username = BotConfig.SteamLogin,
|
Username = BotConfig.SteamLogin,
|
||||||
@@ -1217,14 +1306,7 @@ namespace ArchiSteamFarm {
|
|||||||
// Support and convert SDA files
|
// Support and convert SDA files
|
||||||
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
|
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
|
||||||
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
||||||
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
ImportAuthenticator(maFilePath);
|
||||||
try {
|
|
||||||
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
|
||||||
File.Delete(maFilePath);
|
|
||||||
Logging.LogGenericInfo("Success!", BotName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logging.LogGenericException(e, BotName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
|
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
|
||||||
@@ -1272,7 +1354,7 @@ namespace ArchiSteamFarm {
|
|||||||
break;
|
break;
|
||||||
default: // Unexpected result, shutdown immediately
|
default: // Unexpected result, shutdown immediately
|
||||||
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result, BotName);
|
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result, BotName);
|
||||||
Shutdown();
|
await Shutdown().ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace ArchiSteamFarm {
|
|||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
private BotDatabase() { }
|
private BotDatabase() { }
|
||||||
|
|
||||||
private void Save() {
|
internal void Save() {
|
||||||
lock (FilePath) {
|
lock (FilePath) {
|
||||||
try {
|
try {
|
||||||
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
|
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ using System.Threading.Tasks;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class CardsFarmer {
|
internal sealed class CardsFarmer {
|
||||||
internal readonly ConcurrentDictionary<uint, float> GamesToFarm = new ConcurrentDictionary<uint, float>();
|
internal readonly ConcurrentDictionary<uint, float> GamesToFarm = new ConcurrentDictionary<uint, float>();
|
||||||
internal readonly List<uint> CurrentGamesFarming = new List<uint>();
|
internal readonly HashSet<uint> CurrentGamesFarming = new HashSet<uint>();
|
||||||
|
|
||||||
private readonly ManualResetEvent FarmResetEvent = new ManualResetEvent(false);
|
private readonly ManualResetEvent FarmResetEvent = new ManualResetEvent(false);
|
||||||
private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1);
|
||||||
@@ -47,24 +47,28 @@ namespace ArchiSteamFarm {
|
|||||||
private bool NowFarming = false;
|
private bool NowFarming = false;
|
||||||
|
|
||||||
internal CardsFarmer(Bot bot) {
|
internal CardsFarmer(Bot bot) {
|
||||||
|
if (bot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bot = bot;
|
Bot = bot;
|
||||||
|
|
||||||
if (Timer == null) {
|
if (Program.GlobalConfig.IdleFarmingPeriod > 0 && Timer == null) {
|
||||||
Timer = new Timer(
|
Timer = new Timer(
|
||||||
async e => await CheckGamesForFarming().ConfigureAwait(false),
|
async e => await CheckGamesForFarming().ConfigureAwait(false),
|
||||||
null,
|
null,
|
||||||
TimeSpan.FromMinutes(15), // Delay
|
TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod), // Delay
|
||||||
TimeSpan.FromMinutes(60) // Period
|
TimeSpan.FromHours(Program.GlobalConfig.IdleFarmingPeriod) // Period
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
|
internal static HashSet<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
|
||||||
if (gamesToFarm == null) {
|
if (gamesToFarm == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<uint> result = new List<uint>();
|
HashSet<uint> result = new HashSet<uint>();
|
||||||
foreach (KeyValuePair<uint, float> keyValue in gamesToFarm) {
|
foreach (KeyValuePair<uint, float> keyValue in gamesToFarm) {
|
||||||
if (keyValue.Value >= 2) {
|
if (keyValue.Value >= 2) {
|
||||||
result.Add(keyValue.Key);
|
result.Add(keyValue.Key);
|
||||||
@@ -177,10 +181,10 @@ namespace ArchiSteamFarm {
|
|||||||
if (Bot.BotConfig.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm
|
if (Bot.BotConfig.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm
|
||||||
Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName);
|
Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName);
|
||||||
while (GamesToFarm.Count > 0) {
|
while (GamesToFarm.Count > 0) {
|
||||||
List<uint> gamesToFarmSolo = GetGamesToFarmSolo(GamesToFarm);
|
HashSet<uint> gamesToFarmSolo = GetGamesToFarmSolo(GamesToFarm);
|
||||||
if (gamesToFarmSolo.Count > 0) {
|
if (gamesToFarmSolo.Count > 0) {
|
||||||
while (gamesToFarmSolo.Count > 0) {
|
while (gamesToFarmSolo.Count > 0) {
|
||||||
uint appID = gamesToFarmSolo[0];
|
uint appID = gamesToFarmSolo.First();
|
||||||
if (await FarmSolo(appID).ConfigureAwait(false)) {
|
if (await FarmSolo(appID).ConfigureAwait(false)) {
|
||||||
farmedSomething = true;
|
farmedSomething = true;
|
||||||
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
|
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
|
||||||
@@ -193,7 +197,6 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (FarmMultiple(GamesToFarm)) {
|
if (FarmMultiple(GamesToFarm)) {
|
||||||
farmedSomething = true;
|
|
||||||
Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName);
|
Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName);
|
||||||
} else {
|
} else {
|
||||||
NowFarming = false;
|
NowFarming = false;
|
||||||
@@ -396,7 +399,7 @@ namespace ArchiSteamFarm {
|
|||||||
await StartFarming().ConfigureAwait(false);
|
await StartFarming().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool?> ShouldFarm(ulong appID) {
|
private async Task<bool?> ShouldFarm(uint appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -422,12 +425,12 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
bool? keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
|
bool? keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
|
||||||
for (ushort farmingTime = 0; farmingTime <= 60 * Program.GlobalConfig.MaxFarmingTime && keepFarming.GetValueOrDefault(true); farmingTime += Program.GlobalConfig.FarmingDelay) {
|
for (ushort farmingTime = 0; farmingTime <= 60 * Program.GlobalConfig.MaxFarmingTime && keepFarming.GetValueOrDefault(true); farmingTime += Program.GlobalConfig.FarmingDelay) {
|
||||||
Logging.LogGenericInfo("Still farming: " + appID, Bot.BotName);
|
|
||||||
if (FarmResetEvent.WaitOne(60 * 1000 * Program.GlobalConfig.FarmingDelay)) {
|
if (FarmResetEvent.WaitOne(60 * 1000 * Program.GlobalConfig.FarmingDelay)) {
|
||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
|
keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
|
||||||
|
Logging.LogGenericInfo("Still farming: " + appID, Bot.BotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot.ResetGamesPlayed();
|
Bot.ResetGamesPlayed();
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using SteamKit2;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal static class Debugging {
|
internal static class Debugging {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -33,5 +37,27 @@ namespace ArchiSteamFarm {
|
|||||||
internal static bool IsReleaseBuild => !IsDebugBuild;
|
internal static bool IsReleaseBuild => !IsDebugBuild;
|
||||||
|
|
||||||
internal static bool NetHookAlreadyInitialized { get; set; } = false;
|
internal static bool NetHookAlreadyInitialized { get; set; } = false;
|
||||||
|
|
||||||
|
internal sealed class DebugListener : IDebugListener {
|
||||||
|
private readonly string FilePath;
|
||||||
|
|
||||||
|
internal DebugListener(string filePath) {
|
||||||
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteLine(string category, string msg) {
|
||||||
|
lock (FilePath) {
|
||||||
|
try {
|
||||||
|
File.AppendAllText(FilePath, category + " | " + msg + Environment.NewLine);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logging.LogGenericException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ namespace ArchiSteamFarm {
|
|||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal byte MaxFarmingTime { get; private set; } = 10;
|
internal byte MaxFarmingTime { get; private set; } = 10;
|
||||||
|
|
||||||
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
|
internal byte IdleFarmingPeriod { get; private set; } = 3;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal byte FarmingDelay { get; private set; } = 5;
|
internal byte FarmingDelay { get; private set; } = 5;
|
||||||
|
|
||||||
@@ -63,7 +66,10 @@ namespace ArchiSteamFarm {
|
|||||||
internal byte InventoryLimiterDelay { get; private set; } = 3;
|
internal byte InventoryLimiterDelay { get; private set; } = 3;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal byte HttpTimeout { get; private set; } = 30;
|
internal bool ForceHttp { get; private set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
|
internal byte HttpTimeout { get; private set; } = 60;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal string WCFHostname { get; private set; } = "localhost";
|
internal string WCFHostname { get; private set; } = "localhost";
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal string tradeofferid { get; set; }
|
internal string tradeofferid { get; set; }
|
||||||
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
internal int accountid_other { get; set; }
|
internal uint accountid_other { get; set; }
|
||||||
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
internal ETradeOfferState trade_offer_state { get; set; }
|
internal ETradeOfferState trade_offer_state { get; set; }
|
||||||
@@ -97,7 +97,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal ulong OtherSteamID64 {
|
internal ulong OtherSteamID64 {
|
||||||
get {
|
get {
|
||||||
if (_OtherSteamID64 == 0 && accountid_other != 0) {
|
if (_OtherSteamID64 == 0 && accountid_other != 0) {
|
||||||
_OtherSteamID64 = new SteamID((uint) accountid_other, EUniverse.Public, EAccountType.Individual).ConvertToUInt64();
|
_OtherSteamID64 = new SteamID(accountid_other, EUniverse.Public, EAccountType.Individual).ConvertToUInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _OtherSteamID64;
|
return _OtherSteamID64;
|
||||||
|
|||||||
@@ -71,9 +71,8 @@ namespace ArchiSteamFarm {
|
|||||||
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
|
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
|
||||||
Log("[!] StackTrace: " + exception.StackTrace);
|
Log("[!] StackTrace: " + exception.StackTrace);
|
||||||
|
|
||||||
Exception innerException = exception.InnerException;
|
if (exception.InnerException != null) {
|
||||||
if (innerException != null) {
|
LogGenericException(exception.InnerException, botName, previousMethodName);
|
||||||
LogGenericException(innerException, botName, previousMethodName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +118,9 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
// Write on console only when not awaiting response from user
|
// Write on console only when not awaiting response from user
|
||||||
if (!Program.ConsoleIsBusy) {
|
if (!Program.ConsoleIsBusy) {
|
||||||
Console.Write(loggedMessage);
|
try {
|
||||||
|
Console.Write(loggedMessage);
|
||||||
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogToFile.GetValueOrDefault()) {
|
if (LogToFile.GetValueOrDefault()) {
|
||||||
@@ -129,7 +130,6 @@ namespace ArchiSteamFarm {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogToFile = false;
|
LogToFile = false;
|
||||||
LogGenericException(e);
|
LogGenericException(e);
|
||||||
LogToFile = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ using System.Threading.Tasks;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
internal enum EUserInputType : byte {
|
internal enum EUserInputType : byte {
|
||||||
|
Unknown,
|
||||||
|
DeviceID,
|
||||||
Login,
|
Login,
|
||||||
Password,
|
Password,
|
||||||
PhoneNumber,
|
PhoneNumber,
|
||||||
@@ -46,12 +48,13 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal enum EMode : byte {
|
internal enum EMode : byte {
|
||||||
|
Unknown,
|
||||||
Normal, // Standard most common usage
|
Normal, // Standard most common usage
|
||||||
Client, // WCF client only
|
Client, // WCF client only
|
||||||
Server // Normal + WCF server
|
Server // Normal + WCF server
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string GithubReleaseURL = "https://api.github.com/repos/JustArchi/ArchiSteamFarm/releases";
|
private const string GithubReleaseURL = "https://api.github.com/repos/JustArchi/ArchiSteamFarm/releases"; // GitHub API is HTTPS only
|
||||||
|
|
||||||
internal const string ASF = "ASF";
|
internal const string ASF = "ASF";
|
||||||
internal const string ConfigDirectory = "config";
|
internal const string ConfigDirectory = "config";
|
||||||
@@ -78,7 +81,7 @@ namespace ArchiSteamFarm {
|
|||||||
private static Timer AutoUpdatesTimer;
|
private static Timer AutoUpdatesTimer;
|
||||||
private static EMode Mode = EMode.Normal;
|
private static EMode Mode = EMode.Normal;
|
||||||
|
|
||||||
private static async Task CheckForUpdate() {
|
internal static async Task CheckForUpdate() {
|
||||||
string oldExeFile = ExecutableFile + ".old";
|
string oldExeFile = ExecutableFile + ".old";
|
||||||
|
|
||||||
// We booted successfully so we can now remove old exe file
|
// We booted successfully so we can now remove old exe file
|
||||||
@@ -277,10 +280,17 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
|
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
|
||||||
|
if (userInputType == EUserInputType.Unknown) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
lock (ConsoleLock) {
|
lock (ConsoleLock) {
|
||||||
ConsoleIsBusy = true;
|
ConsoleIsBusy = true;
|
||||||
switch (userInputType) {
|
switch (userInputType) {
|
||||||
|
case EUserInputType.DeviceID:
|
||||||
|
Console.Write("<" + botLogin + "> Please enter your Device ID (including \"android:\"): ");
|
||||||
|
break;
|
||||||
case EUserInputType.Login:
|
case EUserInputType.Login:
|
||||||
Console.Write("<" + botLogin + "> Please enter your login: ");
|
Console.Write("<" + botLogin + "> Please enter your login: ");
|
||||||
break;
|
break;
|
||||||
@@ -307,6 +317,9 @@ namespace ArchiSteamFarm {
|
|||||||
case EUserInputType.TwoFactorAuthentication:
|
case EUserInputType.TwoFactorAuthentication:
|
||||||
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Console.Write("<" + botLogin + "> Please enter not documented yet value of \"" + userInputType + "\": ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
result = Console.ReadLine();
|
result = Console.ReadLine();
|
||||||
Console.Clear(); // For security purposes
|
Console.Clear(); // For security purposes
|
||||||
@@ -334,7 +347,7 @@ namespace ArchiSteamFarm {
|
|||||||
private static void InitServices() {
|
private static void InitServices() {
|
||||||
GlobalConfig = GlobalConfig.Load();
|
GlobalConfig = GlobalConfig.Load();
|
||||||
if (GlobalConfig == null) {
|
if (GlobalConfig == null) {
|
||||||
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.db exists and is valid!");
|
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.json exists and is valid!");
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
Exit(1);
|
Exit(1);
|
||||||
}
|
}
|
||||||
@@ -425,6 +438,18 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If debugging is on, we prepare debug directory prior to running
|
||||||
|
if (GlobalConfig.Debug) {
|
||||||
|
if (Directory.Exists(Program.DebugDirectory)) {
|
||||||
|
Directory.Delete(Program.DebugDirectory, true);
|
||||||
|
Thread.Sleep(1000); // Dirty workaround giving Windows some time to sync
|
||||||
|
}
|
||||||
|
Directory.CreateDirectory(Program.DebugDirectory);
|
||||||
|
|
||||||
|
SteamKit2.DebugLog.AddListener(new Debugging.DebugListener(Path.Combine(Program.DebugDirectory, "debug.txt")));
|
||||||
|
SteamKit2.DebugLog.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse args
|
// Parse args
|
||||||
ParseArgs(args);
|
ParseArgs(args);
|
||||||
|
|
||||||
@@ -454,7 +479,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bot bot = new Bot(botName);
|
Bot bot = new Bot(botName);
|
||||||
if (!bot.BotConfig.Enabled) {
|
if (bot.BotConfig == null || !bot.BotConfig.Enabled) {
|
||||||
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +489,7 @@ namespace ArchiSteamFarm {
|
|||||||
string botName = Path.GetFileNameWithoutExtension(configFile);
|
string botName = Path.GetFileNameWithoutExtension(configFile);
|
||||||
Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!");
|
Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!");
|
||||||
Bot bot = new Bot(botName);
|
Bot bot = new Bot(botName);
|
||||||
if (!bot.BotConfig.Enabled) {
|
if (bot.BotConfig == null || !bot.BotConfig.Enabled) {
|
||||||
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.0.0.3")]
|
[assembly: AssemblyVersion("2.0.0.9")]
|
||||||
[assembly: AssemblyFileVersion("2.0.0.3")]
|
[assembly: AssemblyFileVersion("2.0.0.9")]
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal Trading(Bot bot) {
|
internal Trading(Bot bot) {
|
||||||
|
if (bot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bot = bot;
|
Bot = bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
"AutoUpdates": true,
|
"AutoUpdates": true,
|
||||||
"UpdateChannel": 1,
|
"UpdateChannel": 1,
|
||||||
"MaxFarmingTime": 10,
|
"MaxFarmingTime": 10,
|
||||||
|
"IdleFarmingPeriod": 3,
|
||||||
"FarmingDelay": 5,
|
"FarmingDelay": 5,
|
||||||
"AccountPlayingDelay": 5,
|
"AccountPlayingDelay": 5,
|
||||||
"LoginLimiterDelay": 7,
|
"LoginLimiterDelay": 7,
|
||||||
"InventoryLimiterDelay": 3,
|
"InventoryLimiterDelay": 3,
|
||||||
"HttpTimeout": 30,
|
"ForceHttp": false,
|
||||||
|
"HttpTimeout": 60,
|
||||||
"WCFHostname": "localhost",
|
"WCFHostname": "localhost",
|
||||||
"WCFPort": 1242,
|
"WCFPort": 1242,
|
||||||
"Statistics": true,
|
"Statistics": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user