/// <summary> /// returns all the commands registered as a slash response /// </summary> /// <param name="arg"></param> /// <returns></returns> private SlashResponse GetAllTheCommands(SlashCommand arg) { var response = new SlashResponse() { response_type = SlashResponseType.in_channel, text = $"Hello Everyone! The app Allthings supports these commands: {string.Concat(_commandImplementers.Keys.Select(k => k + "\n"))}" }; return(response); }
/// <summary> /// The below method used for sending resposne back to slack for a slash command in ephemeral mood. Required field response_url. /// </summary> /// <param name="leave">Slash Command object</param> /// <param name="replyText">Text to be send to slack</param> public void SendMessage(SlashCommand leave, string replyText) { var text = new SlashResponse() { ResponseType = _stringConstant.ResponseTypeEphemeral, Text = replyText }; var textJson = JsonConvert.SerializeObject(text); WebRequestMethod(textJson, leave.ResponseUrl); }
/// <summary> /// Previousy implemented command, but intentionally omitted to test failures /// </summary> /// <param name="arg"></param> /// <returns></returns> private SlashResponse ProcessBasicCommand(SlashCommand arg) { var retVal = new SlashResponse() { response_type = SlashResponseType.in_channel, text = "Beginners All Purpose Symbolic Instruction Code" }; return(retVal); }
/// <summary> /// Method to setup for Send Message of client /// </summary> /// <param name="replyText">reply text</param> /// <returns>json string</returns> private string MockingSendMessageAsync(string replyText) { var slashResponseText = new SlashResponse() { ResponseType = _stringConstant.ResponseTypeEphemeral, Text = replyText }; var slashResponseJsonText = JsonConvert.SerializeObject(slashResponseText); PostAsyncMethodMocking(It.IsAny <string>(), slashResponseJsonText, _stringConstant.JsonContentString); return(slashResponseJsonText); }
/// <summary> /// The below method used for sending resposne back to slack for a slash command in ephemeral mood. Required field response_url. /// </summary> /// <param name="responseUrl">Incoming Web-hook url of user to whom message to be send</param> /// <param name="replyText">Text to be send to slack</param> public async Task SendMessageAsync(string responseUrl, string replyText) { _logger.Debug("SendMessageAsync method"); var slashResponseText = new SlashResponse() { ResponseType = _stringConstant.ResponseTypeEphemeral, Text = replyText }; var slashResponseJsonText = JsonConvert.SerializeObject(slashResponseText); await _httpClientService.PostAsync(responseUrl, slashResponseJsonText, _stringConstant.JsonContentString, null, null); _logger.Debug("SendMessageAsync method post method done sucessfully"); }
private async Task <SlashResponse> GetSlashResponseForBartStation(string stationCode) { BartResponse bartResponse = await GetBartResponseForStation(stationCode); var response = new SlashResponse() { response_type = SlashResponseType.ephemeral, text = string.Concat( bartResponse.Root.Station.First().Etd.Select(dest => $"|To *{dest.Destination}* {GetMinutes(dest.Estimate.First().Minutes.ToString())}|\n")) }; return(response); }
public SlashResponse ProcessCommand(SlashCommand incoming) { if (_commandImplementers.TryGetValue(incoming.command, out ISlashCommandImplementer implementer)) { return(implementer.ProcessCommand(incoming)); } else { var error = new SlashResponse() { response_type = SlashResponseType.ephemeral, text = "Something is amiss. I am not ready to accept that command" }; return(error); } }
private SlashResponse SendHelpResponse() { if (_response == null) { var helpText = new StringBuilder(); helpText.AppendLine("To see bart schedule at a stop, use the station code. Following are the station codes for reference"); var stationCodes = string.Concat(_bartStations.Select(kvp => $"||Code: *{kvp.Key}*, Station: *{kvp.Value}*||")); helpText.AppendLine(stationCodes); _response = new SlashResponse() { response_type = SlashResponseType.ephemeral, text = helpText.ToString() }; } return(_response); }
public SlashResponse ProcessCommand(SlashCommand arg) { var searchQuery = new MediaWikiNET.Models.SearchRequest(arg.text); var searchResult = _mediaWiki.Search(searchQuery); var returnResult = searchResult.query?.search.FirstOrDefault()?.snippet; if (string.IsNullOrEmpty(returnResult)) { returnResult = "Can't help you with that"; } else { returnResult = PostProcessWikiSnippet(returnResult); } var retVal = new SlashResponse() { response_type = SlashResponseType.ephemeral, text = returnResult }; return(retVal); }