|
|
|
|
@@ -172,15 +172,9 @@ namespace ArchiSteamFarm {
|
|
|
|
|
SentryFile = botPath + ".bin";
|
|
|
|
|
|
|
|
|
|
// Support and convert SDA files
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(botPath + ".maFile")) {
|
|
|
|
|
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", botName);
|
|
|
|
|
try {
|
|
|
|
|
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(botPath + ".maFile"));
|
|
|
|
|
File.Delete(botPath + ".maFile");
|
|
|
|
|
Logging.LogGenericInfo("Success!", botName);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logging.LogGenericException(e, botName);
|
|
|
|
|
}
|
|
|
|
|
string maFilePath = botPath + ".maFile";
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
|
|
|
|
ImportAuthenticator(maFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
|
@@ -262,16 +256,16 @@ namespace ArchiSteamFarm {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
|
|
|
|
|
if (confirmations == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) {
|
|
|
|
|
Logging.LogGenericInfo("Accepting confirmation: Success!", BotName);
|
|
|
|
|
@@ -283,6 +277,9 @@ namespace ArchiSteamFarm {
|
|
|
|
|
Logging.LogGenericWarning("Accepting confirmation: Failed!", 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);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logging.LogGenericException(e, BotName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -329,6 +326,10 @@ namespace ArchiSteamFarm {
|
|
|
|
|
case "!exit":
|
|
|
|
|
Program.Exit();
|
|
|
|
|
return null;
|
|
|
|
|
case "!farm":
|
|
|
|
|
return await ResponseFarm().ConfigureAwait(false);
|
|
|
|
|
case "!loot":
|
|
|
|
|
return await ResponseSendTrade().ConfigureAwait(false);
|
|
|
|
|
case "!rejoinchat":
|
|
|
|
|
return ResponseRejoinChat();
|
|
|
|
|
case "!restart":
|
|
|
|
|
@@ -340,8 +341,9 @@ namespace ArchiSteamFarm {
|
|
|
|
|
return ResponseStatusAll();
|
|
|
|
|
case "!stop":
|
|
|
|
|
return ResponseStop();
|
|
|
|
|
case "!loot":
|
|
|
|
|
return await ResponseSendTrade().ConfigureAwait(false);
|
|
|
|
|
case "!update":
|
|
|
|
|
await Program.CheckForUpdate().ConfigureAwait(false);
|
|
|
|
|
return "Done!";
|
|
|
|
|
default:
|
|
|
|
|
return "Unrecognized command: " + message;
|
|
|
|
|
}
|
|
|
|
|
@@ -360,6 +362,10 @@ namespace ArchiSteamFarm {
|
|
|
|
|
} else {
|
|
|
|
|
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":
|
|
|
|
|
if (args.Length > 2) {
|
|
|
|
|
return await ResponsePlay(args[1], args[2]).ConfigureAwait(false);
|
|
|
|
|
@@ -374,12 +380,10 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
case "!start":
|
|
|
|
|
return await ResponseStart(args[1]).ConfigureAwait(false);
|
|
|
|
|
case "!stop":
|
|
|
|
|
return ResponseStop(args[1]);
|
|
|
|
|
case "!status":
|
|
|
|
|
return ResponseStatus(args[1]);
|
|
|
|
|
case "!loot":
|
|
|
|
|
return await ResponseSendTrade(args[1]).ConfigureAwait(false);
|
|
|
|
|
case "!stop":
|
|
|
|
|
return ResponseStop(args[1]);
|
|
|
|
|
default:
|
|
|
|
|
return "Unrecognized command: " + args[0];
|
|
|
|
|
}
|
|
|
|
|
@@ -422,6 +426,62 @@ namespace ArchiSteamFarm {
|
|
|
|
|
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() {
|
|
|
|
|
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.";
|
|
|
|
|
@@ -562,6 +622,24 @@ namespace ArchiSteamFarm {
|
|
|
|
|
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) {
|
|
|
|
|
if (string.IsNullOrEmpty(message)) {
|
|
|
|
|
return null;
|
|
|
|
|
@@ -895,6 +973,9 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
|
|
|
|
|
|
|
|
|
InitializeLoginAndPassword();
|
|
|
|
|
|
|
|
|
|
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
|
|
|
|
LoginResult loginResult;
|
|
|
|
|
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
|
|
|
|
@@ -957,6 +1038,16 @@ namespace ArchiSteamFarm {
|
|
|
|
|
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) {
|
|
|
|
|
if (callback == null) {
|
|
|
|
|
return;
|
|
|
|
|
@@ -985,13 +1076,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
InitializeLoginAndPassword();
|
|
|
|
|
|
|
|
|
|
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
|
|
|
|
Username = BotConfig.SteamLogin,
|
|
|
|
|
@@ -1217,14 +1302,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
// Support and convert SDA files
|
|
|
|
|
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
ImportAuthenticator(maFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
|
|
|
|
|
|