Example #1
0
        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);

            try {
                await Utilities.InParallel(Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*" + SharedInfo.ConfigExtension).Select(Path.GetFileNameWithoutExtension).Where(botName => !string.IsNullOrEmpty(botName) && IsValidBotName(botName)).OrderBy(botName => botName).Select(Bot.RegisterBot)).ConfigureAwait(false);
            } catch (Exception e) {
                ArchiLogger.LogGenericException(e);
                return;
            }

            if (Bot.Bots.Count == 0)
            {
                ArchiLogger.LogGenericWarning(Strings.ErrorNoBotsDefined);
            }
        }