コード例 #1
0
ファイル: SlackWebClient.cs プロジェクト: KK578/bashi-old
        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);
        }
コード例 #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.");
        }
コード例 #3
0
ファイル: SlackEventLogger.cs プロジェクト: KK578/bashi-old
 public void AttachLogger()
 {
     slackRtmEventPublisher.AllMessages += (s, e) => log.Info(e.Response.ToString());
 }