Exemplo n.º 1
0
        public SendMessageTests()
        {
            this.state  = SlackBotState.Initialize("1", "testbot");
            this.config = new TestConfig();

            this.bus = new RxMessageBus();
        }
Exemplo n.º 2
0
        private SlackBot(
            SlackBotState state,
            IDriver driver,
            IMessageBus bus,
            ISlackBotConfig config,
            ILogger <SlackBot> logger)
        {
            this.state  = state;
            this.config = config;
            this.logger = logger;

            this.driver     = driver;
            this.messageBus = bus;

            this.whenHandlers = new ConcurrentQueue <WhenHandler>();

            this.sendMessageQueue = new MessageThrottleQueue(
                TimeSpan.FromSeconds(1.0), // ~1/sec (see: https://api.slack.com/methods/chat.postMessage)
                driver,
                logger,
                (queue, msg, lg, ex) =>
            {
                config?.OnSendMessageFailure?.Invoke(queue, msg, lg, ex);
            });

            this.uploadFileQueue = new ThrottleQueue <File>(
                TimeSpan.FromSeconds(3), // ~20/min (see: https://api.slack.com/methods/files.upload)
                logger,
                this.driver.UploadFileAsync,
                null);
        }
Exemplo n.º 3
0
        public BotInitializeTests()
        {
            this.state  = SlackBotState.Initialize("1", "testbot");
            this.config = new TestConfig();

            this.driver = new TestDriver(this.state);
            this.bus    = new RxMessageBus();
        }
Exemplo n.º 4
0
        public async Task InitializeAsync()
        {
            this.state  = SlackBotState.Initialize("1", "testbot");
            this.config = new TestConfig();

            this.driver = new TestDriver(this.state);
            this.bus    = new RxMessageBus();

            this.bot = await SlackBot.InitializeAsync(this.driver, this.bus);
        }
Exemplo n.º 5
0
        private SlackBot(
            SlackBotState state,
            IDriver driver,
            IMessageBus bus,
            ISlackBotConfig config,
            ILogger <SlackBot> logger)
        {
            this.state  = state;
            this.config = config;
            this.logger = logger;

            this.driver     = driver;
            this.messageBus = bus;

            this.whenHandlers = new ConcurrentQueue <WhenHandler>();

            this.sendMessageQueue = new SendMessageQueue(TimeSpan.FromSeconds(1), driver, logger, config.OnSendMessageFailure);
        }