mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Never register bot with broken database, closes #265
This commit is contained in:
@@ -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 + "!";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user