public void SetUp() { _rtm = Substitute.For <ISlackRtmClient>(); _incomingMessages = new Subject <MessageEvent>(); _rtm.Messages.Returns(_incomingMessages); _api = Substitute.For <ISlackApiClient>(); _scheduler = new TestScheduler(); _sut = new SlackBot(_rtm, _api, _scheduler); }
public void SetUp() { _rtm = Substitute.For <ISlackRtmClient>(); _incomingMessages = new Subject <MessageEvent>(); _rtm.Messages.Returns(_incomingMessages); _api = Substitute.For <ISlackApiClient>(); _scheduler = new TestScheduler(); _scheduler.AdvanceTo(TimeSpan.FromMinutes(1).Ticks); // So first message isn't queued _sut = new SlackBot(_rtm, _api, _scheduler); }
public SlackBot(ISlackRtmClient rtmClient, ISlackApiClient apiClient, IScheduler scheduler = null) { _rtm = rtmClient; _api = apiClient; _scheduler = scheduler ?? Scheduler.Default; _incomingWithMiddlewareApplied = _rtm.Messages .Where(m => m.GetType() == typeof(MessageEvent) || m.GetType() == typeof(Events.BotMessage)) .Where(m => m.User != Id) .SelectMany(CreateSlackMessage); _outgoingWithMiddlewareApplied = _outgoingMessages .LimitFrequency(TimeSpan.FromSeconds(1), m => m.CancellationToken ?? CancellationToken.None, _scheduler); }
public SlackConnectionManager(ISlackConfigGroup slackConfigGroup, ISlackRtmClient slackRtmClient, ISlackWebClient slackWebClient, ISlackConnectionEventPublisher slackConnectionEventPublisher, IBashiLogger log) { botToken = slackConfigGroup.BotToken; this.slackRtmClient = slackRtmClient; this.slackWebClient = slackWebClient; this.log = log; slackConnectionEventPublisher.RtmDisconnected += (s, e) => Connect(); }