Exemplo n.º 1
0
        public async Task <RtmConnectResponse> RtmConnectAsync(string token)
        {
            const string url = "https://slack.com/api/rtm.connect";

            var values = new Dictionary <string, string> {
                { "token", token }
            };
            var content = new FormUrlEncodedContent(values);

            log.Info($"POST {url} - Sent");
            var response = await httpClient.PostAsync(url, content);

            var responseContent = await response.Content.ReadAsStringAsync();

            log.Info($"POST {url} - {responseContent}");

            var connectResponse = JsonConvert.DeserializeObject <RtmConnectResponse>(responseContent);

            return(connectResponse);
        }
Exemplo n.º 2
0
        private async void SetupRtmClient()
        {
            var connectResponse = await slackWebClient.RtmConnectAsync(botToken);

            if (string.IsNullOrEmpty(connectResponse.WebSocketUrl))
            {
                throw new Exception("No Websocket Url from RtmConnect.");
            }

            await slackRtmClient.ConnectAsync(connectResponse.WebSocketUrl);

            log.Info("Connected to RTM API.");
        }
Exemplo n.º 3
0
 public void AttachLogger()
 {
     slackRtmEventPublisher.AllMessages += (s, e) => log.Info(e.Response.ToString());
 }