Exemplo n.º 1
0
        /// <summary>
        /// Load the configuration from a .bot file.
        /// </summary>
        /// <param name="file">Path to bot file. </param>
        /// <param name="secret">Secret to use to decrypt the file on disk. </param>
        /// <returns><see cref="BotConfiguration"/>.</returns>
        public static BotConfiguration Load(string file, string secret = null)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException(nameof(file));
            }

            return(BotConfiguration.LoadAsync(file, secret).GetAwaiter().GetResult());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the bot configuration by looking in a folder and finding the first .bot file in the folder.
        /// </summary>
        /// <param name="folder">folder to look for bot files</param>
        /// <param name="secret">secret to use to encrypt keys</param>
        /// <returns>task for BotConfiguration</returns>
        public static async Task <BotConfiguration> LoadFromFolderAsync(string folder, string secret = null)
        {
            var file = Directory.GetFiles(folder, "*.bot", SearchOption.TopDirectoryOnly).FirstOrDefault();

            if (file != null)
            {
                return(await BotConfiguration.LoadAsync(file, secret));
            }

            throw new FileNotFoundException($"Error: no bot file found in {folder}. Choose a different location or use msbot init to create a.bot file.");
        }