mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-09-20 14:32:05 +00:00
Closes #607
This commit is contained in:
parent
6a035f4832
commit
ad187c0d88
3 changed files with 34 additions and 3 deletions
|
@ -96,7 +96,6 @@ namespace ArchiSteamFarm {
|
|||
private bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown);
|
||||
private string SentryFile => BotPath + ".bin";
|
||||
|
||||
[JsonProperty]
|
||||
internal BotConfig BotConfig { get; private set; }
|
||||
|
||||
[JsonProperty]
|
||||
|
|
|
@ -85,33 +85,39 @@ namespace ArchiSteamFarm {
|
|||
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.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType));
|
||||
Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName));
|
||||
result = Console.ReadLine();
|
||||
break;
|
||||
}
|
||||
|
||||
result = Console.ReadLine();
|
||||
|
||||
if (!Console.IsOutputRedirected) {
|
||||
Console.Clear(); // For security purposes
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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) {
|
||||
if (action == null) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(action));
|
||||
|
|
Loading…
Reference in a new issue