This commit is contained in:
JustArchi 2017-08-05 22:35:03 +02:00
parent 6a035f4832
commit ad187c0d88
3 changed files with 34 additions and 3 deletions

View file

@ -96,7 +96,6 @@ namespace ArchiSteamFarm {
private bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown); private bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown);
private string SentryFile => BotPath + ".bin"; private string SentryFile => BotPath + ".bin";
[JsonProperty]
internal BotConfig BotConfig { get; private set; } internal BotConfig BotConfig { get; private set; }
[JsonProperty] [JsonProperty]

View file

@ -85,33 +85,39 @@ namespace ArchiSteamFarm {
switch (userInputType) { switch (userInputType) {
case ASF.EUserInputType.DeviceID: case ASF.EUserInputType.DeviceID:
Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName));
result = Console.ReadLine();
break; break;
case ASF.EUserInputType.IPCHostname: case ASF.EUserInputType.IPCHostname:
Console.Write(Bot.FormatBotResponse(Strings.UserInputIPCHost, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputIPCHost, botName));
result = Console.ReadLine();
break; break;
case ASF.EUserInputType.Login: case ASF.EUserInputType.Login:
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName));
result = Console.ReadLine();
break; break;
case ASF.EUserInputType.Password: case ASF.EUserInputType.Password:
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName));
result = Utilities.ReadLineMasked();
break; break;
case ASF.EUserInputType.SteamGuard: case ASF.EUserInputType.SteamGuard:
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName));
result = Console.ReadLine();
break; break;
case ASF.EUserInputType.SteamParentalPIN: case ASF.EUserInputType.SteamParentalPIN:
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalPIN, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalPIN, botName));
result = Utilities.ReadLineMasked();
break; break;
case ASF.EUserInputType.TwoFactorAuthentication: case ASF.EUserInputType.TwoFactorAuthentication:
Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName)); Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName));
result = Console.ReadLine();
break; break;
default: default:
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType));
Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName)); Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName));
result = Console.ReadLine();
break; break;
} }
result = Console.ReadLine();
if (!Console.IsOutputRedirected) { if (!Console.IsOutputRedirected) {
Console.Clear(); // For security purposes Console.Clear(); // For security purposes
} }

View file

@ -29,6 +29,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Humanizer; using Humanizer;
@ -85,6 +86,31 @@ namespace ArchiSteamFarm {
} }
} }
internal static string ReadLineMasked(char mask = '*') {
StringBuilder result = new StringBuilder();
ConsoleKeyInfo keyInfo;
while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Enter) {
if (!char.IsControl(keyInfo.KeyChar)) {
result.Append(keyInfo.KeyChar);
Console.Write(mask);
} else if ((keyInfo.Key == ConsoleKey.Backspace) && (result.Length > 0)) {
result.Remove(result.Length - 1, 1);
if (Console.CursorLeft == 0) {
Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1);
Console.Write(' ');
Console.SetCursorPosition(Console.BufferWidth - 1, Console.CursorTop - 1);
} else {
Console.Write("\b \b");
}
}
}
Console.WriteLine();
return result.ToString();
}
internal static void StartBackgroundAction(Action action, bool longRunning = true) { internal static void StartBackgroundAction(Action action, bool longRunning = true) {
if (action == null) { if (action == null) {
ASF.ArchiLogger.LogNullError(nameof(action)); ASF.ArchiLogger.LogNullError(nameof(action));