// token = args[0] // dbType = args[1] // dbConnection = args[2] public async Task MainAsync(string[] args) { string token; IFactory <IRepository> repositoryFactory = new MemoryRepositoryFactory(); if (args != null && args.Length > 0) { token = args[0]; if (args.Length == 3) { var connection = DbConnections[args[1]]; connection.ConnectionString = args[2]; repositoryFactory = new DbRepositoryFactory { Connection = DbConnections[args[1]], QueryProvider = DbQueryProviders[args[1]] }; } } else { token = Environment.GetEnvironmentVariable("SweatyBoyBotToken"); foreach (var variable in DbTypes) { var connectionString = Environment.GetEnvironmentVariable(variable); if (!string.IsNullOrEmpty(connectionString)) { var connection = DbConnections[variable]; connection.ConnectionString = connectionString; repositoryFactory = new DbRepositoryFactory { Connection = connection, QueryProvider = DbQueryProviders[variable] }; break; } } } if (string.IsNullOrEmpty(token)) { Console.WriteLine($"Environment variable SweatyBoyBotToken not found"); return; } var discordClient = new DiscordSocketClient(); discordClient.Log += Log; _bot = new BotShell(discordClient, token, new HttpClient(), repositoryFactory.Get()); await _bot.Start(); await _bot.Routine(); }
public void Setup() { this.Factory = new MemoryRepositoryFactory(); }
public void Setup() { this.Factory = new MemoryRepositoryFactory(); }