This commit is contained in:
JustArchi
2017-04-23 22:08:33 +02:00
parent a6c448340d
commit 77e46fda0e
2 changed files with 22 additions and 6 deletions

View File

@@ -221,7 +221,7 @@ namespace ArchiSteamFarm {
continue;
}
new Bot(botName).Forget();
Bot.RegisterBot(botName);
}
if (Bot.Bots.Count == 0) {
@@ -263,7 +263,7 @@ namespace ArchiSteamFarm {
return;
}
new Bot(botName).Forget();
Bot.RegisterBot(botName);
}
private static async void OnChanged(object sender, FileSystemEventArgs e) {

View File

@@ -122,7 +122,7 @@ namespace ArchiSteamFarm {
private string TwoFactorCode;
private byte TwoFactorCodeFailures;
internal Bot(string botName) {
private Bot(string botName) {
if (string.IsNullOrEmpty(botName)) {
throw new ArgumentNullException(nameof(botName));
}
@@ -225,8 +225,6 @@ namespace ArchiSteamFarm {
TimeSpan.FromMinutes(1) + TimeSpan.FromMinutes(0.2 * Bots.Count), // Delay
TimeSpan.FromMinutes(1) // Period
);
InitStart().Forget();
}
public void Dispose() {
@@ -583,6 +581,24 @@ namespace ArchiSteamFarm {
return false;
}
internal static void RegisterBot(string botName) {
if (string.IsNullOrEmpty(botName)) {
ASF.ArchiLogger.LogNullError(nameof(botName));
return;
}
Bot bot;
try {
bot = new Bot(botName);
} catch (ArgumentException e) {
ASF.ArchiLogger.LogGenericException(e);
return;
}
bot.InitStart().Forget();
}
internal void RequestPersonaStateUpdate() {
if (!IsConnectedAndLoggedOn) {
return;
@@ -1119,7 +1135,7 @@ namespace ArchiSteamFarm {
ArchiLogger.LogGenericError(Strings.BotHeartBeatFailed);
Destroy(true);
new Bot(BotName).Forget();
RegisterBot(BotName);
}
private async Task InitStart() {