Beispiel #1
0
        static void Main(string[] args)
        {
            // Set up configuration sources.
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Path.Combine(AppContext.BaseDirectory))
                                .AddJsonFile("appsettings.json", false)
                                .Build();

            var logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(configuration)
                         .CreateLogger();

            var roms = configuration["RomsDirectory"] != null?Rom.ScanDirectory(logger, configuration["RomsDirectory"]) : null;

            var bots = new List <JanitraBot>();

            foreach (var child in configuration.GetSection("JanitraBots").GetChildren())
            {
                var options = new JanitraBotOptions(child["AccessKey"], int.Parse(child["JanitraBotId"]), child["ProfileDir"]);

                bots.Add(new JanitraBot(new Client(child["BaseUrl"]), logger, options, roms));
            }

            foreach (var bot in bots)
            {
                Console.WriteLine("Running bot " + bot.Options.JanitraBotId);
                bot.RunOnce().Wait();
            }
        }
Beispiel #2
0
 public JanitraBot(IClient client, ILogger logger, JanitraBotOptions options, List <Rom> roms)
 {
     _client = client;
     _logger = logger;
     Options = options;
     _roms   = roms;
 }