Example #1
0
        public AdminMiddleware(IMiddleware next, AdminPlugin adminPlugin, SchedulePlugin schedulePlugin, ISlackWrapper slackWrapper) : base(next)
        {
            _adminPlugin    = adminPlugin;
            _schedulePlugin = schedulePlugin;
            _slackWrapper   = slackWrapper;

            HandlerMappings = new[]
            {
                new HandlerMapping
                {
                    ValidHandles  = new [] { "admin pin" },
                    EvaluatorFunc = PinHandler
                },
                new HandlerMapping
                {
                    ValidHandles  = new [] { "admin schedules list" },
                    EvaluatorFunc = SchedulesListHandler
                },
                new HandlerMapping
                {
                    ValidHandles  = new [] { "admin schedules delete" },
                    EvaluatorFunc = DeleteSchedulesHandler
                },
                new HandlerMapping
                {
                    ValidHandles  = new [] { "admin channels" },
                    EvaluatorFunc = ChannelsHandler
                }
            };
        }
Example #2
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 #3
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();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error connecting to Slack: {0}", task.Exception);
                    }
                });
        }
Example #4
0
 public SchedulePlugin(StoragePlugin storagePlugin, ISlackWrapper slackWrapper, StatsPlugin statsPlugin)
 {
     _storagePlugin = storagePlugin;
     _slackWrapper  = slackWrapper;
     _statsPlugin   = statsPlugin;
 }
Example #5
0
 public PingPlugin(ISlackWrapper slackWrapper)
 {
     _slackWrapper = slackWrapper;
 }
Example #6
0
 public PingPlugin(ISlackWrapper slackWrapper, StoragePlugin storagePlugin)
 {
     _slackWrapper  = slackWrapper;
     _storagePlugin = storagePlugin;
 }