internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF) { if (userInputType == ASF.EUserInputType.Unknown) { return(null); } if (GlobalConfig.Headless) { ASF.ArchiLogger.LogGenericWarning(Strings.ErrorUserInputRunningInHeadlessMode); return(null); } string result; lock (ConsoleLock) { Logging.OnUserInputStart(); switch (userInputType) { case ASF.EUserInputType.DeviceID: Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName)); result = Console.ReadLine(); break; case ASF.EUserInputType.IPCHostname: Console.Write(Bot.FormatBotResponse(Strings.UserInputIPCHost, botName)); result = Console.ReadLine(); break; case ASF.EUserInputType.Login: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName)); result = Console.ReadLine(); break; case ASF.EUserInputType.Password: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName)); result = Utilities.ReadLineMasked(); break; case ASF.EUserInputType.SteamGuard: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName)); result = Console.ReadLine(); break; case ASF.EUserInputType.SteamParentalPIN: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalPIN, botName)); result = Utilities.ReadLineMasked(); break; case ASF.EUserInputType.TwoFactorAuthentication: Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName)); result = Console.ReadLine(); break; default: ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName)); result = Console.ReadLine(); break; } if (!Console.IsOutputRedirected) { Console.Clear(); // For security purposes } Logging.OnUserInputEnd(); } return(!string.IsNullOrEmpty(result) ? result.Trim() : null); }
internal static string GetUserInput(SharedInfo.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) { if (userInputType == SharedInfo.EUserInputType.Unknown) { return(null); } if (GlobalConfig.Headless || !Runtime.IsUserInteractive) { ASF.ArchiLogger.LogGenericWarning("Received a request for user input, but process is running in headless mode!"); return(null); } string result; lock (ConsoleLock) { Logging.OnUserInputStart(); switch (userInputType) { case SharedInfo.EUserInputType.DeviceID: Console.Write("<" + botName + "> Please enter your Device ID (including \"android:\"): "); break; case SharedInfo.EUserInputType.Login: Console.Write("<" + botName + "> Please enter your login: "******"<" + botName + "> Please enter your password: "******"<" + botName + "> Please enter your full phone number (e.g. +1234567890): "); break; case SharedInfo.EUserInputType.SMS: Console.Write("<" + botName + "> Please enter SMS code sent on your mobile: "); break; case SharedInfo.EUserInputType.SteamGuard: Console.Write("<" + botName + "> Please enter the auth code sent to your email: "); break; case SharedInfo.EUserInputType.SteamParentalPIN: Console.Write("<" + botName + "> Please enter steam parental PIN: "); break; case SharedInfo.EUserInputType.RevocationCode: Console.WriteLine("<" + botName + "> PLEASE WRITE DOWN YOUR REVOCATION CODE: " + extraInformation); Console.Write("<" + botName + "> Hit enter once ready..."); break; case SharedInfo.EUserInputType.TwoFactorAuthentication: Console.Write("<" + botName + "> Please enter your 2 factor auth code from your authenticator app: "); break; case SharedInfo.EUserInputType.WCFHostname: Console.Write("<" + botName + "> Please enter your WCF hostname: "); break; default: Console.Write("<" + botName + "> Please enter not documented yet value of \"" + userInputType + "\": "); break; } result = Console.ReadLine(); if (!Console.IsOutputRedirected) { Console.Clear(); // For security purposes } Logging.OnUserInputEnd(); } return(!string.IsNullOrEmpty(result) ? result.Trim() : null); }