private static CommandResponse HandleTrack(GitHubUser user, Command command) { try { string text = command.text, action = text.Split(' ')[0]; string repository = text.Split(' ').Length >= 2 ? command.text.Substring(text.IndexOf(action) + (action.Length + 1)) : ""; if (!string.IsNullOrEmpty(repository) && user.TrackRepository(repository)) { if (repository == "*") { repository = "*all repositories*"; } return(new CommandResponse("*Successfully tracked* " + repository)); } else { StringBuilder sb = new StringBuilder(); sb.AppendLine("*Here are your available untracked repositories:* "); sb.AppendLine(FormatRepositoryList(user.UntrackedRepositories)); return(new CommandResponse(sb.ToString())); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(new CommandResponse(":cry: There was an error processing your request. Please try again.")); } }
private static CommandResponse HandleTrack(GitHubUser user, Command command) { string text = command.text, action = text.Split(' ')[0]; string repository = text.Split(' ').Length >= 2 ? command.text.Substring(text.IndexOf(action) + (action.Length + 1)) : ""; if (user.TrackRepository(repository)) { return(new CommandResponse("*Successfully tracked* " + repository)); } else { StringBuilder sb = new StringBuilder(); sb.AppendLine("*Here are your available untracked repositories:* "); sb.AppendLine(FormatRepositoryList(user.UntrackedRepositories)); return(new CommandResponse(sb.ToString())); } }