diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 7f0fc73f3..3c4d7f9e7 100644 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -183,9 +183,19 @@ namespace ArchiSteamFarm { sentryHash = CryptoHelper.SHAHash(sentryFileContent); } + string steamLogin = SteamLogin; + if (string.IsNullOrEmpty(steamLogin) || steamLogin.Equals("null")) { + steamLogin = Program.GetUserInput(BotName, Program.EUserInputType.Login); + } + + string steamPassword = SteamPassword; + if (string.IsNullOrEmpty(steamPassword) || steamPassword.Equals("null")) { + steamPassword = Program.GetUserInput(BotName, Program.EUserInputType.Password); + } + SteamUser.LogOn(new SteamUser.LogOnDetails { - Username = SteamLogin, - Password = SteamPassword, + Username = steamLogin, + Password = steamPassword, AuthCode = AuthCode, TwoFactorCode = TwoFactorAuth, SentryFileHash = sentryHash @@ -284,10 +294,10 @@ namespace ArchiSteamFarm { EResult result = callback.Result; switch (result) { case EResult.AccountLogonDenied: - AuthCode = Program.GetSteamGuardCode(SteamLogin, false); + AuthCode = Program.GetUserInput(SteamLogin, Program.EUserInputType.SteamGuard); break; case EResult.AccountLoginDeniedNeedTwoFactor: - TwoFactorAuth = Program.GetSteamGuardCode(SteamLogin, true); + TwoFactorAuth = Program.GetUserInput(SteamLogin, Program.EUserInputType.TwoFactorAuthentication); break; case EResult.OK: Logging.LogGenericInfo(BotName, "Successfully logged on!"); diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index ce8e5254d..f7d79d447 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -29,6 +29,13 @@ using System.Threading; namespace ArchiSteamFarm { internal static class Program { + internal enum EUserInputType { + Login, + Password, + SteamGuard, + TwoFactorAuthentication, + } + internal const string ConfigDirectoryPath = "config"; private static readonly HashSet Bots = new HashSet(); internal static readonly object ConsoleLock = new object(); @@ -38,15 +45,25 @@ namespace ArchiSteamFarm { Environment.Exit(exitCode); } - internal static string GetSteamGuardCode(string botLogin, bool twoFactorAuthentication) { + internal static string GetUserInput(string botLogin, EUserInputType userInputType) { 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 : "); + switch (userInputType) { + case EUserInputType.Login: + Console.Write("<" + botLogin + "> Please enter your login: "); + break; + case EUserInputType.Password: + Console.Write("<" + botLogin + "> Please enter your password: "); + break; + case EUserInputType.SteamGuard: + Console.Write("<" + botLogin + "> Please enter the auth code sent to your email : "); + break; + case EUserInputType.TwoFactorAuthentication: + Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: "); + break; } result = Console.ReadLine(); + Console.Clear(); // For security purposes } return result; } diff --git a/ArchiSteamFarm/config/example.xml b/ArchiSteamFarm/config/example.xml index 02cd9195a..f7b51c69a 100644 --- a/ArchiSteamFarm/config/example.xml +++ b/ArchiSteamFarm/config/example.xml @@ -4,27 +4,35 @@ + + + + - + + + - + + + \ No newline at end of file