Exemple #1
0
        protected async Task <bool> Respond(SlackRequest request, SlackResponse response)
        {
            var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
                RequestUri = new Uri(request.ResponseUrl),
                Method     = HttpMethod.Post,
                Content    = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json")
            });

            return(httpResponse.StatusCode == HttpStatusCode.OK);
        }
Exemple #2
0
        protected async Task <bool> Respond(SlackRequest request, SlackResponse response)
        {
            using (var stream = new MemoryStream()) {
                JsonSerializer.Serialize(response, stream);
                stream.Position = 0;
                var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
                    RequestUri = new Uri(request.ResponseUrl),
                    Method     = HttpMethod.Post,
                    Content    = new StreamContent(stream)
                });

                return(httpResponse.StatusCode == HttpStatusCode.OK);
            }
        }
Exemple #3
0
 protected Task <bool> RespondEphemeral(SlackRequest request, string text, params SlackResponseAttachment[] attachments)
 => Respond(request, SlackResponse.Ephemeral(text, attachments));
Exemple #4
0
 protected Task <bool> RespondInChannel(SlackRequest request, string text, params SlackResponseAttachment[] attachments)
 => Respond(request, SlackResponse.InChannel(text, attachments));