diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 9549c8dba..e1133c56d 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -124,17 +124,17 @@ namespace ArchiSteamFarm { } } - internal Bot(string botName, bool initialLaunch = false) { + internal Bot(string botName) { if (Bots.ContainsKey(botName)) { return; } BotName = botName; - ConfigFile = Path.Combine(Program.ConfigDirectory, BotName + ".xml"); - LoginKeyFile = Path.Combine(Program.ConfigDirectory, BotName + ".key"); - MobileAuthenticatorFile = Path.Combine(Program.ConfigDirectory, BotName + ".auth"); - SentryFile = Path.Combine(Program.ConfigDirectory, BotName + ".bin"); + ConfigFile = Path.Combine(Program.ConfigDirectory, botName + ".xml"); + LoginKeyFile = Path.Combine(Program.ConfigDirectory, botName + ".key"); + MobileAuthenticatorFile = Path.Combine(Program.ConfigDirectory, botName + ".auth"); + SentryFile = Path.Combine(Program.ConfigDirectory, botName + ".bin"); if (!ReadConfig()) { return; @@ -144,7 +144,7 @@ namespace ArchiSteamFarm { return; } - Bots.AddOrUpdate(BotName, this, (key, value) => this); + Bots[botName] = this; // Initialize SteamClient = new SteamClient(); @@ -167,7 +167,11 @@ namespace ArchiSteamFarm { CallbackManager.Subscribe(OnFriendMsgHistory); if (UseAsfAsMobileAuthenticator && File.Exists(MobileAuthenticatorFile)) { - SteamGuardAccount = JsonConvert.DeserializeObject(File.ReadAllText(MobileAuthenticatorFile)); + try { + SteamGuardAccount = JsonConvert.DeserializeObject(File.ReadAllText(MobileAuthenticatorFile)); + } catch (Exception e) { + Logging.LogGenericException(e, botName); + } } SteamUser = SteamClient.GetHandler(); @@ -187,14 +191,14 @@ namespace ArchiSteamFarm { if (SendTradePeriod > 0 && SendItemsTimer == null) { SendItemsTimer = new Timer( - async e => await ResponseSendTrade(BotName).ConfigureAwait(false), + async e => await ResponseSendTrade().ConfigureAwait(false), null, TimeSpan.FromHours(SendTradePeriod), // Delay TimeSpan.FromHours(SendTradePeriod) // Period ); } - if (initialLaunch && !StartOnLaunch) { + if (!StartOnLaunch) { return; } diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 3990b4ccc..408ab5e2b 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -40,8 +40,8 @@ namespace ArchiSteamFarm { private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1); private readonly Bot Bot; - private readonly Timer Timer; + internal readonly Timer Timer; internal readonly ConcurrentDictionary GamesToFarm = new ConcurrentDictionary(); internal readonly List CurrentGamesFarming = new List(); diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 3a85ea61d..1337c37c9 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -269,7 +269,7 @@ namespace ArchiSteamFarm { foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) { string botName = Path.GetFileNameWithoutExtension(configFile); - Bot bot = new Bot(botName, true); + Bot bot = new Bot(botName); if (!bot.Enabled) { Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName); }