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); }
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."); }
public void AttachLogger() { slackRtmEventPublisher.AllMessages += (s, e) => log.Info(e.Response.ToString()); }