mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 06:50:29 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07049e71c0 | ||
|
|
4710d9c1eb | ||
|
|
d08462745a |
@@ -172,15 +172,9 @@ namespace ArchiSteamFarm {
|
|||||||
SentryFile = botPath + ".bin";
|
SentryFile = botPath + ".bin";
|
||||||
|
|
||||||
// Support and convert SDA files
|
// Support and convert SDA files
|
||||||
if (BotDatabase.SteamGuardAccount == null && File.Exists(botPath + ".maFile")) {
|
string maFilePath = botPath + ".maFile";
|
||||||
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", botName);
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
||||||
try {
|
ImportAuthenticator(maFilePath);
|
||||||
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(botPath + ".maFile"));
|
|
||||||
File.Delete(botPath + ".maFile");
|
|
||||||
Logging.LogGenericInfo("Success!", botName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logging.LogGenericException(e, botName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
@@ -432,6 +426,62 @@ namespace ArchiSteamFarm {
|
|||||||
Program.OnBotShutdown();
|
Program.OnBotShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ImportAuthenticator(string maFilePath) {
|
||||||
|
if (BotDatabase.SteamGuardAccount != null || !File.Exists(maFilePath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
||||||
|
try {
|
||||||
|
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
||||||
|
File.Delete(maFilePath);
|
||||||
|
Logging.LogGenericInfo("Success!", BotName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logging.LogGenericException(e, BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is SDA file, then we should already have everything ready
|
||||||
|
if (BotDatabase.SteamGuardAccount.Session != null) {
|
||||||
|
Logging.LogGenericInfo("Successfully finished importing mobile authenticator!", BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// But here we're dealing with WinAuth authenticator
|
||||||
|
Logging.LogGenericInfo("ASF requires a few more steps to complete authenticator import...", BotName);
|
||||||
|
|
||||||
|
InitializeLoginAndPassword();
|
||||||
|
|
||||||
|
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
||||||
|
LoginResult loginResult;
|
||||||
|
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
||||||
|
switch (loginResult) {
|
||||||
|
case LoginResult.Need2FA:
|
||||||
|
userLogin.TwoFactorCode = Program.GetUserInput(BotName, Program.EUserInputType.TwoFactorAuthentication);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logging.LogGenericError("Unhandled situation: " + loginResult, BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userLogin.Session == null) {
|
||||||
|
BotDatabase.SteamGuardAccount = null;
|
||||||
|
Logging.LogGenericError("Session is invalid, linking can't be completed!", BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BotDatabase.SteamGuardAccount.FullyEnrolled = true;
|
||||||
|
BotDatabase.SteamGuardAccount.Session = userLogin.Session;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(BotDatabase.SteamGuardAccount.DeviceID)) {
|
||||||
|
BotDatabase.SteamGuardAccount.DeviceID = Program.GetUserInput(BotName, Program.EUserInputType.DeviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
BotDatabase.Save();
|
||||||
|
Logging.LogGenericInfo("Successfully finished importing mobile authenticator!", BotName);
|
||||||
|
}
|
||||||
|
|
||||||
private string ResponseStatus() {
|
private string ResponseStatus() {
|
||||||
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
|
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
|
||||||
return "Bot " + BotName + " is currently farming appIDs: " + string.Join(", ", CardsFarmer.CurrentGamesFarming) + " and has a total of " + CardsFarmer.GamesToFarm.Count + " games left to farm.";
|
return "Bot " + BotName + " is currently farming appIDs: " + string.Join(", ", CardsFarmer.CurrentGamesFarming) + " and has a total of " + CardsFarmer.GamesToFarm.Count + " games left to farm.";
|
||||||
@@ -923,6 +973,9 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
||||||
|
|
||||||
|
InitializeLoginAndPassword();
|
||||||
|
|
||||||
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
UserLogin userLogin = new UserLogin(BotConfig.SteamLogin, BotConfig.SteamPassword);
|
||||||
LoginResult loginResult;
|
LoginResult loginResult;
|
||||||
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
while ((loginResult = userLogin.DoLogin()) != LoginResult.LoginOkay) {
|
||||||
@@ -985,6 +1038,16 @@ namespace ArchiSteamFarm {
|
|||||||
SteamFriends.JoinChat(BotConfig.SteamMasterClanID);
|
SteamFriends.JoinChat(BotConfig.SteamMasterClanID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializeLoginAndPassword() {
|
||||||
|
if (string.IsNullOrEmpty(BotConfig.SteamLogin)) {
|
||||||
|
BotConfig.SteamLogin = Program.GetUserInput(BotName, Program.EUserInputType.Login);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(BotConfig.SteamPassword) && string.IsNullOrEmpty(BotDatabase.LoginKey)) {
|
||||||
|
BotConfig.SteamPassword = Program.GetUserInput(BotName, Program.EUserInputType.Password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
return;
|
return;
|
||||||
@@ -1013,13 +1076,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BotConfig.SteamLogin)) {
|
InitializeLoginAndPassword();
|
||||||
BotConfig.SteamLogin = Program.GetUserInput(BotName, Program.EUserInputType.Login);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BotConfig.SteamPassword) && string.IsNullOrEmpty(BotDatabase.LoginKey)) {
|
|
||||||
BotConfig.SteamPassword = Program.GetUserInput(BotName, Program.EUserInputType.Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
SteamUser.LogOn(new SteamUser.LogOnDetails {
|
||||||
Username = BotConfig.SteamLogin,
|
Username = BotConfig.SteamLogin,
|
||||||
@@ -1245,14 +1302,7 @@ namespace ArchiSteamFarm {
|
|||||||
// Support and convert SDA files
|
// Support and convert SDA files
|
||||||
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
|
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
|
||||||
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
|
||||||
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
ImportAuthenticator(maFilePath);
|
||||||
try {
|
|
||||||
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
|
||||||
File.Delete(maFilePath);
|
|
||||||
Logging.LogGenericInfo("Success!", BotName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logging.LogGenericException(e, BotName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
|
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace ArchiSteamFarm {
|
|||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
private BotDatabase() { }
|
private BotDatabase() { }
|
||||||
|
|
||||||
private void Save() {
|
internal void Save() {
|
||||||
lock (FilePath) {
|
lock (FilePath) {
|
||||||
try {
|
try {
|
||||||
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
|
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ using System.Threading.Tasks;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
internal enum EUserInputType : byte {
|
internal enum EUserInputType : byte {
|
||||||
|
Unknown,
|
||||||
|
DeviceID,
|
||||||
Login,
|
Login,
|
||||||
Password,
|
Password,
|
||||||
PhoneNumber,
|
PhoneNumber,
|
||||||
@@ -277,10 +279,17 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
|
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
|
||||||
|
if (userInputType == EUserInputType.Unknown) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
lock (ConsoleLock) {
|
lock (ConsoleLock) {
|
||||||
ConsoleIsBusy = true;
|
ConsoleIsBusy = true;
|
||||||
switch (userInputType) {
|
switch (userInputType) {
|
||||||
|
case EUserInputType.DeviceID:
|
||||||
|
Console.Write("<" + botLogin + "> Please enter your Device ID (including \"android:\"): ");
|
||||||
|
break;
|
||||||
case EUserInputType.Login:
|
case EUserInputType.Login:
|
||||||
Console.Write("<" + botLogin + "> Please enter your login: ");
|
Console.Write("<" + botLogin + "> Please enter your login: ");
|
||||||
break;
|
break;
|
||||||
@@ -307,6 +316,9 @@ namespace ArchiSteamFarm {
|
|||||||
case EUserInputType.TwoFactorAuthentication:
|
case EUserInputType.TwoFactorAuthentication:
|
||||||
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
Console.Write("<" + botLogin + "> Please enter your 2 factor auth code from your authenticator app: ");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Console.Write("<" + botLogin + "> Please enter not documented yet value of \"" + userInputType + "\": ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
result = Console.ReadLine();
|
result = Console.ReadLine();
|
||||||
Console.Clear(); // For security purposes
|
Console.Clear(); // For security purposes
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.0.0.7")]
|
[assembly: AssemblyVersion("2.0.0.8")]
|
||||||
[assembly: AssemblyFileVersion("2.0.0.7")]
|
[assembly: AssemblyFileVersion("2.0.0.8")]
|
||||||
|
|||||||
Reference in New Issue
Block a user