From 82c2d3ec15c21e674c8b3d21e11424c2666835da Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 27 Jun 2016 00:38:38 +0200 Subject: [PATCH] Never register bot with broken database, closes #265 --- ArchiSteamFarm/Bot.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 6c98212c6..cae1fda29 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -135,10 +135,15 @@ namespace ArchiSteamFarm { throw new ArgumentNullException(nameof(botName)); } - BotName = botName; + if (Bots.ContainsKey(botName)) { + throw new Exception("That bot is already defined!"); + } string botPath = Path.Combine(Program.ConfigDirectory, botName); + BotName = botName; + SentryFile = botPath + ".bin"; + BotConfig = BotConfig.Load(botPath + ".json"); if (BotConfig == null) { Logging.LogGenericError("Your bot config is invalid, refusing to start this bot instance!", botName); @@ -150,14 +155,6 @@ namespace ArchiSteamFarm { return; } - if (Bots.ContainsKey(botName)) { - throw new Exception("That bot is already defined!"); - } - - Bots[botName] = this; - - SentryFile = botPath + ".bin"; - BotDatabase = BotDatabase.Load(botPath + ".db"); if (BotDatabase == null) { Logging.LogGenericError("Bot database could not be loaded, refusing to start this bot instance!", botName); @@ -248,6 +245,9 @@ namespace ArchiSteamFarm { ); } + // Register bot as available for ASF + Bots[botName] = this; + if (!BotConfig.StartOnLaunch) { return; } @@ -993,6 +993,7 @@ namespace ArchiSteamFarm { if (Bots.TryGetValue(botName, out bot)) { return await bot.ResponseRedeem(steamID, message, validate).ConfigureAwait(false); } + if (IsOwner(steamID)) { return "Couldn't find any bot named " + botName + "!"; }