private async Task CreateIssueDialogResume(IDialogContext context, IAwaitable <CreateIssueDialog> result) { CreateIssueDialog issue = await result; string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { string msg; Issue i = await GitHubCommands.CreateIssue(token, _lastRepo, issue.Title, issue.Comment); if (i != null) { msg = $"I have created the [new issue]({i.HtmlUrl})."; } else { msg = "I could not locate the repo, or you don't have permission to create an issue in it."; } await context.PostAsync(msg); } context.Wait(MessageReceived); }
private async Task IssueDetailIssueResume(IDialogContext context, IAwaitable <double> result) { _lastIssue = (int)await result; string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { string msg; Issue issue = await GitHubCommands.GetIssue(token, _lastRepo, _lastIssue); if (issue == null) { msg = $"That issue doesn't exist in the **{_lastRepo}** repo, the repo itself doesn't exist, or you don't have access to it."; } else { msg = $"Here are some details for issue **{_lastIssue}** in the **{_lastRepo}** repo:" + Environment.NewLine + Environment.NewLine + $"**Name:** [{issue.Title}]({issue.HtmlUrl})" + Environment.NewLine + Environment.NewLine + $"**Opened by:** [{issue.User.Login}]({issue.User.HtmlUrl})" + Environment.NewLine + Environment.NewLine + $"**State:** {issue.State}" + Environment.NewLine + Environment.NewLine + $"---" + Environment.NewLine + Environment.NewLine + $"{issue.Body}"; } await context.PostAsync(msg); } context.Wait(MessageReceived); }
private async Task CloseIssueConfirmResume(IDialogContext context, IAwaitable <bool> result) { string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { string msg; bool yesno = await result; if (yesno) { if (await GitHubCommands.CloseIssue(token, _lastRepo, _lastIssue)) { msg = $"I have closed issue {_lastIssue}."; } else { msg = "I could not locate the repo, the issue, or you don't have permission to close it."; } } else { msg = $"I have **not** closed issue {_lastIssue}."; } await context.PostAsync(msg); } context.Wait(MessageReceived); }
protected override async Task MessageReceived(IDialogContext context, IAwaitable <IMessageActivity> item) { IMessageActivity message = await item; if (message.Text.ToLower().Contains("login") || message.Text.ToLower().Contains("log in")) { await GitHubCommands.LogIn(context); } else if (message.Text.ToLower().Contains("logout") || message.Text.ToLower().Contains("log out")) { await Logout(context); } else if (message.Text.ToLower().Contains("help")) { await Help(context, null); } else if (message.Text.ToLower().Contains("reset")) { await Reset(context); } else if (message.Text.ToLower().Contains("authenticated")) { await Authenticated(context); } else { string token; context.UserData.TryGetValue(Constants.AuthTokenKey, out token); await base.MessageReceived(context, item); } }
private async Task ListIssuesResume(IDialogContext context, IAwaitable <string> repo) { _lastRepo = await repo; string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { IReadOnlyList <Issue> issues = await GitHubCommands.GetIssueList(token, _lastRepo, _lastDate); string msg; if (issues == null) { msg = "That repo doesn't exist or you don't have access to it. Try another one?"; } else if (!issues.Any()) { msg = $"There are no issues assigned to you in the **{_lastRepo}** repo."; } else { msg = issues.Aggregate($"These issues from the **{_lastRepo}** repo are assigned to you:", (current, issue) => current + Environment.NewLine + $"* [{issue.Number}]({issue.HtmlUrl}): {issue.Title}"); } await context.PostAsync(msg); } _lastDate = null; context.Wait(MessageReceived); }
public async Task ListRepos(IDialogContext context, LuisResult result) { string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { EntityRecommendation eScope; result.TryFindEntity("ScopeType::Scope", out eScope); IReadOnlyList <Repository> repos = await GitHubCommands.GetRepoList(token, eScope?.Entity); string msg; if (!repos.Any()) { msg = "You don't own any repos on GitHub."; } else { msg = repos.Aggregate($"You own the following {eScope?.Entity} repos: ", (current, repo) => current + Environment.NewLine + $"* [{repo.Name}]({repo.HtmlUrl})"); } await context.PostAsync(msg); } context.Wait(MessageReceived); }
private async Task GetRepo(IDialogContext context, string token, ResumeAfter <string> resume) { if (string.IsNullOrEmpty(_lastRepo)) { IReadOnlyList <Repository> list = await GitHubCommands.GetRepoList(token, string.Empty); IEnumerable <string> repos = list.Select(i => i.Name); PromptDialog.Choice(context, resume, repos, "Which repo are you asking about?", "I didn't catch that...try again?"); } else { await resume(context, Awaitable.FromItem(_lastRepo)); } }
public async Task TypeCount(IDialogContext context, LuisResult result) { string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { EntityRecommendation eScope, eType; result.TryFindEntity("ScopeType::Scope", out eScope); result.TryFindEntity("ScopeType::Type", out eType); if (eType != null) { if (eType.Entity.ToLower().Contains("repo")) { int count = await GitHubCommands.GetRepoCount(token, eScope?.Entity); await context.PostAsync($"You have {count} {eScope?.Entity} repos."); } else if (eType.Entity.ToLower().Contains("issue")) { int count = await GitHubCommands.GetIssueCount(token); await context.PostAsync($"You have {count} issues."); } else if (eType.Entity.ToLower().Contains("pull") || eType.Entity.ToLower().Contains("pr")) { EntityRecommendation repoName; if (result.TryFindEntity("RepoName", out repoName)) { int count = await GitHubCommands.GetPullRequestCount(token, repoName.Entity); await context.PostAsync($"You have {count} PRs in the {repoName.Entity} repo."); } else { await None(context, result); } } } else { await None(context, result); } } context.Wait(MessageReceived); }
private async Task IssueCommentFinalResume(IDialogContext context, IAwaitable <string> comment) { string c = await comment; string token = await ValidateLoggedInAsync(context); if (!string.IsNullOrEmpty(token)) { IssueComment ic = await GitHubCommands.AddComment(token, _lastRepo, _lastIssue, c); if (ic != null) { await context.PostAsync($"I have added your comment to [issue {_lastIssue}]({ic.HtmlUrl})."); } else { await context.PostAsync($"I could not add your comment to issue {_lastIssue}."); } } context.Wait(MessageReceived); }