Пример #1
0
        public SlackResponse ProcessRequest(SlackRequest request)
        {
            try
            {
                if (request.text == null)
                {
                    return new SlackResponse("Please type some text containing a jira ticket key");
                }
                var jiraKeys = JiraTicketRegex.Matches(request.text).Cast<Match>();
                if (!jiraKeys.Any())
                {
                    return   new SlackResponse("Couldn't find any ticket keys");
                }

                var attachments = jiraKeys.Select(match => new SlackResponse.Attachment
                {
                    fallback = _jiraUrl + match,
                    text = string.Format("<{0}{1}|{1}>", _jiraUrl, match.ToString().ToUpper()),
                    color = "good"
                });

                return new SlackResponse
                {
                    response_type = "in_channel",
                    attachments = attachments
                };
            }
            catch (Exception ex)
            {
                return
                    new SlackResponse($"Unable to parse request text '{request.text}', got an error '{ex.StackTrace}'");
            }
        }
Пример #2
0
 public SlackResponse Post(SlackRequest request)
 {
     return _jiraCommand.ProcessRequest(request);
 }