internal static async Task InitBots()
{
if (Bot.Bots.Count != 0)
{
return;
}
// Before attempting to connect, initialize our configuration
await Bot.InitializeSteamConfiguration(Program.GlobalConfig.SteamProtocols, Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider).ConfigureAwait(false);
HashSet <string> botNames;
try {
botNames = Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*" + SharedInfo.ConfigExtension).Select(Path.GetFileNameWithoutExtension).Where(botName => !string.IsNullOrEmpty(botName) && IsValidBotName(botName)).ToHashSet();
} catch (Exception e) {
ArchiLogger.LogGenericException(e);
return;
}
if (botNames.Count == 0)
{
ArchiLogger.LogGenericWarning(Strings.ErrorNoBotsDefined);
return;
}
if (botNames.Count > MaximumRecommendedBotsCount)
{
ArchiLogger.LogGenericWarning(string.Format(Strings.WarningExcessiveBotsCount, MaximumRecommendedBotsCount));
await Task.Delay(10000).ConfigureAwait(false);
}
await Utilities.InParallel(botNames.OrderBy(botName => botName).Select(Bot.RegisterBot)).ConfigureAwait(false);
}