コード例 #1
0
        // 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();
        }
コード例 #2
0
 public void Setup()
 {
   this.Factory = new MemoryRepositoryFactory();
 }
コード例 #3
0
 public void Setup()
 {
     this.Factory = new MemoryRepositoryFactory();
 }