Example #1
0
 public SlackBotCore(IConfigReader configReader, ILogger logger, INoobotContainer container)
 {
     this._configReader    = configReader;
     this._logger          = logger;
     this._container       = container;
     this._averageResponse = new AverageStat("milliseconds");
 }
Example #2
0
 public NoobotCore(IConfigReader configReader, ILog log, INoobotContainer container)
 {
     _configReader    = configReader;
     _log             = log;
     _container       = container;
     _averageResponse = new AverageStat("milliseconds");
 }
Example #3
0
        public void Start()
        {
            AppDomain.CurrentDomain.ProcessExit += this.ProcessExitHandler;
            Console.CancelKeyPress += this.ConsoleOnCancelKeyPress;

            IServiceCollection serviceBuilder = new ServiceCollection()
                                                .AddSingleton <ISpotifyBase, SpotifyBase>();

            ILogger          test             = this.GetLogger(serviceBuilder);
            ContainerFactory containerFactory =
                new ContainerFactory(this._configuration, this._configReader, test);

            INoobotContainer container = containerFactory.CreateContainer();

            this._slackBotCore = container.GetNoobotCore();


            this._slackBotCore
            .Connect()
            .ContinueWith(task =>
            {
                if (!task.IsCompleted || task.IsFaulted)
                {
                    Console.WriteLine($"Error connecting to Slack: {task.Exception}");
                }
            })
            .GetAwaiter()
            .GetResult();

            _quitEvent.WaitOne();


            //serviceBuilder.BuildServiceProvider();
        }
Example #4
0
 public NoobotCore(IConfigReader configReader, ILog log, INoobotContainer container)
 {
     _configReader = configReader;
     _log = log;
     _container = container;
     _averageResponse = new AverageStat("milliseconds");
 }
Example #5
0
        public void Start()
        {
            INoobotContainer container = _containerGenerator.Generate();

            _slackWrapper = container.GetSlackConnector();

            Console.WriteLine("Connecting...");
            _slackWrapper
            .Connect()
            .ContinueWith(task =>
            {
                if (task.IsCompleted && !task.IsFaulted)
                {
                    _plugins = container.GetPlugins();
                    foreach (IPlugin plugin in _plugins)
                    {
                        plugin.Start();
                    }

                    container.GetInstance <StatsPlugin>().RecordStat("Connected since", DateTime.Now.ToString("G"));
                }
                else
                {
                    Console.WriteLine($"Error connecting to Slack: {task.Exception}");
                }
            });
        }
Example #6
0
        public void Start()
        {
            IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, LogManager.GetLogger(GetType()));
            INoobotContainer  container        = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            Console.WriteLine("Connecting...");
            _noobotCore
            .Connect()
            .ContinueWith(task =>
            {
                if (!task.IsCompleted || task.IsFaulted)
                {
                    Console.WriteLine($"Error connecting to Slack: {task.Exception}");
                }

                Settings.ChannelList = _noobotCore.ListChannels();

                var lastRun = DateTime.UtcNow;
                while (true)
                {
                    if (lastRun.AddSeconds(1) <= DateTime.UtcNow)
                    {
                        var check = new MunkCheck();
                        check.CheckForEvents(_noobotCore);

                        lastRun = DateTime.UtcNow;
                    }
                }
            })
            .Wait();
        }
Example #7
0
        public void Setup()
        {
            var containerFactory = new ContainerFactory(new ToolboxConfiguration(), new ConfigReader(), NoobotWrapper.GetLogger());
            _container = containerFactory.CreateContainer();

            _noobotCore = _container.GetNoobotCore();
            _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1));
        }
        public void Setup()
        {
            var containerFactory = new ContainerFactory(new ToolboxConfiguration(), new JsonConfigReader(), NoobotWrapper.GetLogger());

            _container = containerFactory.CreateContainer();

            _noobotCore = _container.GetNoobotCore();
            _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1));
        }
        public void Setup()
        {
            File.Delete(Path.Combine(Environment.CurrentDirectory, "data/schedules.json"));

            var containerFactory = new ContainerFactory(new SchedulerConfig(), new ConfigReader(), NoobotWrapper.GetLogger());
            _container = containerFactory.CreateContainer();

            _noobotCore = _container.GetNoobotCore();
            _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1));
        }
Example #10
0
        public void Setup()
        {
            File.Delete(Path.Combine(Environment.CurrentDirectory, "data/schedules.json"));

            var containerFactory = new ContainerFactory(new SchedulerConfig(), new ConfigReader(), NoobotWrapper.GetLogger());

            _container = containerFactory.CreateContainer();

            _noobotCore = _container.GetNoobotCore();
            _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1));
        }
Example #11
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            IContainerFactory containerFactory = new ContainerFactory(_botConfiguration,
                                                                      _configReader, LogManager.GetLogger(GetType()));
            INoobotContainer container = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            _logger.LogInformation("Connecting..");
            await _noobotCore.Connect();
        }
Example #12
0
        private static async Task RunNoobot()
        {
            var containerFactory = new ContainerFactory(
                new MiddlewareConfiguration(),
                new JsonConfigReader(_noobotConfigFilePath),
                GetLogger());

            INoobotContainer container = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            await _noobotCore.Connect();
        }
Example #13
0
        private static async Task RunNoobot()
        {
            var containerFactory = new ContainerFactory(
                new ConfigurationBase(),
                JsonConfigReader.DefaultLocation(),
                GetLogger());

            INoobotContainer container = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            await _noobotCore.Connect();
        }
Example #14
0
        public INoobotContainer CreateContainer()
        {
            ServiceRegistry registry = CreateRegistry();

            this.SetupSingletons(registry);
            this.SetupMiddlewarePipeline(registry);
            Type[] pluginTypes = this.SetupPlugins(registry);

            registry.For <ISlackBotCore>().Use(x => x.GetInstance <SlackBotCore>());
            registry.For <ILogger>().Use(this._logger);
            registry.For <IConfigReader>().Use(this._configReader);

            INoobotContainer container = CreateContainer(pluginTypes, registry);

            return(container);
        }
Example #15
0
        public INoobotContainer CreateContainer()
        {
            Registry registry = CreateRegistry();

            SetupSingletons(registry);
            SetupMiddlewarePipeline(registry);
            Type[] pluginTypes = SetupPlugins(registry);

            registry.For <INoobotCore>().Use(x => x.GetInstance <NoobotCore>());
            registry.For <ILog>().Use(() => _logger);
            registry.For <IConfigReader>().Use(() => _configReader);

            INoobotContainer container = CreateContainer(pluginTypes, registry);

            return(container);
        }
Example #16
0
        public void Start()
        {
            IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, new ConsoleLog());
            INoobotContainer  container        = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            Console.WriteLine("Connecting...");
            _noobotCore
            .Connect()
            .ContinueWith(task =>
            {
                if (!task.IsCompleted || task.IsFaulted)
                {
                    Console.WriteLine($"Error connecting to Slack: {task.Exception}");
                }
            });
        }
Example #17
0
        public INoobotHost Start()
        {
            INoobotContainer container = _containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            Console.WriteLine("Connecting...");
            _noobotCore
            .Connect()
            .ContinueWith(task =>
            {
                if (!task.IsCompleted || task.IsFaulted)
                {
                    Console.WriteLine($"Error connecting to Slack: {task.Exception}");
                }
            });

            return(this);
        }
Example #18
0
        public void Start(ILog log)
        {
            IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, log);
            INoobotContainer  container        = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            _noobotCore
            .Connect()
            .ContinueWith(task =>
            {
                if (!task.IsCompleted || task.IsFaulted)
                {
                    Debug.WriteLine($"Error connecting to Slack: {task.Exception}");
                }
            })
            .GetAwaiter()
            .GetResult();
        }
Example #19
0
 public void SetContainer(INoobotContainer noobotContainer)
 {
     throw new System.NotImplementedException();
 }
Example #20
0
 public void SetContainer(INoobotContainer noobotContainer)
 {
     throw new System.NotImplementedException();
 }
Example #21
0
 public void SetContainer(INoobotContainer noobotContainer)
 {
     _noobotContainer = noobotContainer;
 }
 public StructuremapJobFactory(INoobotContainer noobotContainer)
 {
     _noobotContainer = noobotContainer;
 }
 public StructuremapJobFactory(INoobotContainer noobotContainer)
 {
     _noobotContainer = noobotContainer;
 }
Example #24
0
 public void SetContainer(INoobotContainer noobotContainer)
 {
     _noobotContainer = noobotContainer;
 }