mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-18 07:20:30 +00:00
Make it possible to enter login/password on each startup
This commit is contained in:
@@ -183,9 +183,19 @@ namespace ArchiSteamFarm {
|
|||||||
sentryHash = CryptoHelper.SHAHash(sentryFileContent);
|
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 {
|
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
||||||
Username = SteamLogin,
|
Username = steamLogin,
|
||||||
Password = SteamPassword,
|
Password = steamPassword,
|
||||||
AuthCode = AuthCode,
|
AuthCode = AuthCode,
|
||||||
TwoFactorCode = TwoFactorAuth,
|
TwoFactorCode = TwoFactorAuth,
|
||||||
SentryFileHash = sentryHash
|
SentryFileHash = sentryHash
|
||||||
@@ -284,10 +294,10 @@ namespace ArchiSteamFarm {
|
|||||||
EResult result = callback.Result;
|
EResult result = callback.Result;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case EResult.AccountLogonDenied:
|
case EResult.AccountLogonDenied:
|
||||||
AuthCode = Program.GetSteamGuardCode(SteamLogin, false);
|
AuthCode = Program.GetUserInput(SteamLogin, Program.EUserInputType.SteamGuard);
|
||||||
break;
|
break;
|
||||||
case EResult.AccountLoginDeniedNeedTwoFactor:
|
case EResult.AccountLoginDeniedNeedTwoFactor:
|
||||||
TwoFactorAuth = Program.GetSteamGuardCode(SteamLogin, true);
|
TwoFactorAuth = Program.GetUserInput(SteamLogin, Program.EUserInputType.TwoFactorAuthentication);
|
||||||
break;
|
break;
|
||||||
case EResult.OK:
|
case EResult.OK:
|
||||||
Logging.LogGenericInfo(BotName, "Successfully logged on!");
|
Logging.LogGenericInfo(BotName, "Successfully logged on!");
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
|
internal enum EUserInputType {
|
||||||
|
Login,
|
||||||
|
Password,
|
||||||
|
SteamGuard,
|
||||||
|
TwoFactorAuthentication,
|
||||||
|
}
|
||||||
|
|
||||||
internal const string ConfigDirectoryPath = "config";
|
internal const string ConfigDirectoryPath = "config";
|
||||||
private static readonly HashSet<Bot> Bots = new HashSet<Bot>();
|
private static readonly HashSet<Bot> Bots = new HashSet<Bot>();
|
||||||
internal static readonly object ConsoleLock = new object();
|
internal static readonly object ConsoleLock = new object();
|
||||||
@@ -38,15 +45,25 @@ namespace ArchiSteamFarm {
|
|||||||
Environment.Exit(exitCode);
|
Environment.Exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetSteamGuardCode(string botLogin, bool twoFactorAuthentication) {
|
internal static string GetUserInput(string botLogin, EUserInputType userInputType) {
|
||||||
string result;
|
string result;
|
||||||
lock (ConsoleLock) {
|
lock (ConsoleLock) {
|
||||||
if (twoFactorAuthentication) {
|
switch (userInputType) {
|
||||||
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
case EUserInputType.Login:
|
||||||
} else {
|
Console.Write("<" + botLogin + "> Please enter your login: ");
|
||||||
Console.Write("<" + botLogin + "> Please enter the auth code sent to your email : ");
|
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();
|
result = Console.ReadLine();
|
||||||
|
Console.Clear(); // For security purposes
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,27 +4,35 @@
|
|||||||
<!-- Every bot should have it's own unique .xml configuration file, this is example on which you can base on -->
|
<!-- Every bot should have it's own unique .xml configuration file, this is example on which you can base on -->
|
||||||
|
|
||||||
<!-- Master switch to turn account on and off, set to "true" after you're done -->
|
<!-- Master switch to turn account on and off, set to "true" after you're done -->
|
||||||
|
<!-- TIP: This bot instance won't run unless below switch is set to "true" -->
|
||||||
<Enabled type="bool" value="false"/>
|
<Enabled type="bool" value="false"/>
|
||||||
|
|
||||||
<!-- This is your steam login, the one you use for logging in to steam -->
|
<!-- This is your steam login, the one you use for logging in to steam -->
|
||||||
|
<!-- TIP: You can use "null" if you wish to enter login on every startup -->
|
||||||
<SteamLogin type="string" value="Foo"/>
|
<SteamLogin type="string" value="Foo"/>
|
||||||
|
|
||||||
<!-- This is your steam password, the one you use for logging in to steam -->
|
<!-- This is your steam password, the one you use for logging in to steam -->
|
||||||
|
<!-- TIP: You can use "null" if you wish to enter password on every startup -->
|
||||||
<SteamPassword type="string" value="Bar"/>
|
<SteamPassword type="string" value="Bar"/>
|
||||||
|
|
||||||
<!-- This is steam nickname, the one you want to use for bot. Can be anything up to 32 characters -->
|
<!-- This is steam nickname, the one you want to use for bot. Can be anything up to 32 characters -->
|
||||||
|
<!-- TIP: You can use "null" if you wish to preserve your actual nickname -->
|
||||||
<SteamNickname type="string" value="null"/>
|
<SteamNickname type="string" value="null"/>
|
||||||
|
|
||||||
<!-- Get one at https://steamcommunity.com/dev/apikey while logged in as bot, domain doesn't matter. You can also use "null", but that will disable many API functions, e.g. trading -->
|
<!-- This is your bot's API key, get one at https://steamcommunity.com/dev/apikey while logged in as bot, domain doesn't matter -->
|
||||||
|
<!-- TIP: You can use "null", but it will disable all API-based functionalities such as trading -->
|
||||||
<SteamApiKey type="string" value="null"/>
|
<SteamApiKey type="string" value="null"/>
|
||||||
|
|
||||||
<!-- This is steamID of the bot-master - you, in steamID64 format -->
|
<!-- This is steamID of the bot-master - you, in steamID64 format -->
|
||||||
|
<!-- TIP: You can use "0", but bot won't accept steam cd-keys or trades from anybody" -->
|
||||||
<SteamMasterID type="ulong" value="76561198006963719"/>
|
<SteamMasterID type="ulong" value="76561198006963719"/>
|
||||||
|
|
||||||
<!-- If you want from the bot to join particular chat of given clan, set it here, otherwise leave at 0 -->
|
<!-- This defines clan of the master, bot will join chatroom of that clan automatically after logging in -->
|
||||||
|
<!-- TIP: You most likely don't want to change it -->
|
||||||
<SteamMasterClanID type="ulong" value="0"/>
|
<SteamMasterClanID type="ulong" value="0"/>
|
||||||
|
|
||||||
<!-- Comma-separated list of IDs that should not be considered for farming -->
|
<!-- Comma-separated list of IDs that should not be considered for farming -->
|
||||||
|
<!-- TIP: You most likely don't want to change it -->
|
||||||
<Blacklist type="HashSet(uint)" value="368020"/>
|
<Blacklist type="HashSet(uint)" value="368020"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in New Issue
Block a user