当前位置: 首页>>代码示例>>C#>>正文


C# IResponse.Send方法代码示例

本文整理汇总了C#中IResponse.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IResponse.Send方法的具体用法?C# IResponse.Send怎么用?C# IResponse.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IResponse的用法示例。


在下文中一共展示了IResponse.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var username = parameters[1];
            var repoName = parameters[3];

            var activeRepositories = Brain.Get<AvailableRepositories>();

            var repo = activeRepositories.SingleOrDefault(r => r.Name == repoName);

            if (repo == null)
            {
                await response.Send("Repository not found, please add it using: mmbot add repo " + repoName).IgnoreWaitContext();
                return;
            }

            if (username.ToLower() == "my self")
            {
                repo.Caretaker = CurrentUser.Name;
            }
            else
            {
                repo.Caretaker = username;
            }

            Brain.Set(activeRepositories);

            await response.Send(username + " is now caretaker for " + repo.Name);
        }
开发者ID:adamralph,项目名称:PBot,代码行数:28,代码来源:RegisterCaretaker.cs

示例2: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var username = response.User.Name;

            var repoNames = Brain.Get<AvailableRepositories>()
                .Where(r => r.Caretaker == username)
                .Select(r => r.Name)
                .ToList();

            if (!repoNames.Any())
            {
                await response.Send($"Hey {username} I couldn't find any repos where you're the caretaker? Please type `pbot list caretakers` for instructions on how to join the fun!").IgnoreWaitContext();
                return;
            }

            var client = GitHubClientBuilder.Build();

            var validationErrors = repoNames.SelectMany(repoName =>
            {
                var repo = client.Repository.Get("Particular", repoName).Result;

                return new CheckIssuesForRepository(repo, client)
                    .Execute();
            })
                .ToList();

            if (!validationErrors.Any())
            {
                await response.Send($"Nice job citizen, your repos are squeaky clean!! (Checked {string.Join(", ", repoNames)})").IgnoreWaitContext();
                return;
            }

            await response.Send(FormatErrors(validationErrors)).IgnoreWaitContext();
        }
开发者ID:adamralph,项目名称:PBot,代码行数:34,代码来源:CheckIssuesInMyRepos.cs

示例3: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            string sourceRepo;
            string issueNumberString;
            if (!RepoParser.ParseRepoAndIssueNumber(parameters[1], out sourceRepo, out issueNumberString))
            {
                await response.Send($"I could not parse the source repository and issue number from '{parameters[1]}'. Are you using the correct syntax?");
                return;
            }

            string targetRepo;
            if (!RepoParser.ParseRepo(parameters[2], out targetRepo))
            {
                await response.Send($"I could not parse the target repository from '{parameters[2]}'. Are you using the correct syntax?");
                return;
            }

            int issueNumber;
            if (!int.TryParse(issueNumberString, out issueNumber))
            {
                await response.Send("Issue number should be a valid number dude!");
                return;
            }

            var owner = "Particular";

            await response.Send($"Copying issue https://github.com/{owner}/{sourceRepo}/issues/{issueNumber}").IgnoreWaitContext();

            var newIssue = await IssueUtility.Transfer(owner, sourceRepo, issueNumber, owner, targetRepo, false).IgnoreWaitContext();

            await response.Send($"Issue copied to https://github.com/{owner}/{targetRepo}/issues/{newIssue.Number}").IgnoreWaitContext();
        }
开发者ID:adamralph,项目名称:PBot,代码行数:32,代码来源:CopyIssue.cs

示例4: FetchComic

        private static async Task FetchComic(IResponse<TextMessage> msg, string num)
        {
            var res = await msg.Http(string.Format("http://xkcd.com/{0}/info.0.json", num)).Get();
            if (res.StatusCode == HttpStatusCode.NotFound)
            {
                await msg.Send(string.Format("Comic {0} not found", num));
                return;
            }

            var body = await res.Json();
            await msg.Send((string) body.title, (string) body.img, (string) body.alt);
        }
开发者ID:dcr25568,项目名称:mmbot,代码行数:12,代码来源:Xkcd.cs

示例5: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var client = GitHubClientBuilder.Build();

            await response.Send("Looking for stale issues I am ...");

            var searchRequest = new SearchIssuesRequest
            {
                User = "Particular",
                Labels = new[] { parameters[1], $"\"{InProgressLabel}\"" },
                SortField = IssueSearchSort.Updated,
                State = ItemState.Open
            };
            var searchResults = await client.Search.SearchIssues(searchRequest);

            if (searchResults.TotalCount == 0)
            {
                await response.Send($"No stale issues found for tag `{parameters[1]}`.");
                return;
            }

            foreach (var issue in searchResults.Items)
            {
                var repositoryName = issue.CommentsUrl.AbsolutePath.Split('/')[3];

                var comments = await client.Issue.Comment.GetAllForIssue("Particular", repositoryName, issue.Number);
                var latestComment = comments.OrderByDescending(c => c.CreatedAt).FirstOrDefault();

                var events = await client.Issue.Events.GetAllForIssue("Particular", repositoryName, issue.Number);
                var movedToInProgress = events.Last(e => e.Label != null && e.Label.Name == InProgressLabel);

                var stalenessThreshold = DateTime.UtcNow.Subtract(StalenessPeriod);

                if (issue.CreatedAt > stalenessThreshold)
                {
                    continue;
                }

                if (latestComment != null && latestComment.CreatedAt > stalenessThreshold)
                {
                    continue;
                }

                if (movedToInProgress.CreatedAt > stalenessThreshold)
                {
                    continue;
                }

                await response.Send(issue.HtmlUrl.ToString());
            }

            await response.Send("Done.");
        }
开发者ID:adamralph,项目名称:PBot,代码行数:53,代码来源:ListStaleIssues.cs

示例6: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var reposGroupedByCaretaker = Brain.Get<AvailableRepositories>()
                .Where(r => r.Caretaker != null)
                .GroupBy(r => r.Caretaker)
                .ToList();

            var allBuilds = client.ListProjects()
                .Select(p => p.Name)
                .ToList();

            foreach (var repoGroup in reposGroupedByCaretaker)
            {
                var reposWithNoBuild = repoGroup.Where(r => !allBuilds.Contains(r.Name)).ToList();

                if (reposWithNoBuild.Any())
                {
                    //Until we have a better way excluding repos that doesn't need a build
                    //await response.Send(string.Format("Hi there @{0}! It seems that there is no build setup for {1} Just type `help create` if you want to help setting it up?", repoGroup.Key, string.Join(", ", reposWithNoBuild))).IgnoreWaitContext();
                }

                var reposWithABuild = repoGroup.Where(r => allBuilds.Contains(r.Name)).ToList();

                var reposWithFailedBuilds = reposWithABuild.Where(r => HasFailedBuilds(r.Name))
                    .ToList();

                if (reposWithFailedBuilds.Any())
                {
                    await response.Send($"Hi there @{repoGroup.Key}! It seems that the build is broken for {string.Join(", ", reposWithFailedBuilds)} and since you're the caretaker I thought you would like to be aware. Just type `list failing builds for my repos` to get the details!").IgnoreWaitContext();
                }
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:32,代码来源:NotifyCaretakersOfCurrentlyFailedBuilds.cs

示例7: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var reposGroupedByCaretaker = Brain.Get<AvailableRepositories>()
                .Where(r => r.Caretaker != null)
                .GroupBy(r => r.Caretaker)
                .ToList();

            var client = GitHubClientBuilder.Build();

            foreach (var repoGroup in reposGroupedByCaretaker)
            {
                var validationErrors = repoGroup.SelectMany(r =>
                {
                    var repo = client.Repository.Get("Particular", r.Name).Result;

                    return new CheckIssuesForRepository(repo, client)
                        .Execute();
                })
                .ToList();

                if (!validationErrors.Any())
                {
                    continue;
                }

                await response.Send($"Hi there @{repoGroup.Key}! There is a few issues in {string.Join(", ", repoGroup)} that needs some attention and since you're the caretaker I thought you would like to be aware. Just type `pbot check my repos` if you want me to help you getting started!").IgnoreWaitContext();
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:28,代码来源:RemindCaretakersOfIssuesToBeHandled.cs

示例8: AsciiMeCore

 private static async Task AsciiMeCore(IResponse<TextMessage> msg, string query)
 {
     var res = await msg.Http(String.Format(Url, query))
         .Get();
     
     try
     {
         res.Content.ReadAsStringAsync().ContinueWith(async readTask =>
         {
             await msg.Send(readTask.Result);
         });
     }
     catch (Exception)
     {
         msg.Send("erm....issues, move along");
     }
 }
开发者ID:nardin,项目名称:mmbot,代码行数:17,代码来源:Ascii.cs

示例9: CatMeGifCore

        private static async Task CatMeGifCore(IResponse<TextMessage> msg, int number)
        {
            var xDoc = await msg.Http(string.Format(Url, number)).GetXml();

            try
            {
                var urls = xDoc.SelectNodes("//url");
                foreach (XmlNode url in urls)
                {
                    msg.Send(url.InnerText);
                }
            }
            catch (Exception)
            {
                msg.Send("erm....issues, move along");
            }
        }
开发者ID:holytshirt,项目名称:mmbot,代码行数:17,代码来源:Cats.cs

示例10: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var repoName = parameters[1];
            var client = GitHubClientBuilder.Build();
            var repo = await client.Repository.Get("Particular", repoName);

            var validationErrors = new CheckIssuesForRepository(repo, client)
                .Execute();

            if (!validationErrors.Any())
            {
                await response.Send("Nice job citizen, the repo is clean!").IgnoreWaitContext();
                return;
            }

            await response.Send(FormatErrors(repoName, validationErrors)).IgnoreWaitContext();
        }
开发者ID:adamralph,项目名称:PBot,代码行数:17,代码来源:CheckRepoForIssuesThatNeedsAttention.cs

示例11: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {

            UserCredentials userCredentials;

            if (!Brain.Get<CredentialStore>().TryGetValue(response.User.Name, out userCredentials))
            {
                await response.Send("No credentials found for " + response.User.Name).IgnoreWaitContext();
                return;
            }


            await response.Send("Credentials for " + response.User.Name).IgnoreWaitContext();

            foreach (var credential in userCredentials.Credentials)
            {
                await response.Send(credential.Name + ": " + credential.Value).IgnoreWaitContext();
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:19,代码来源:ListCredentials.cs

示例12: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var apiKey = Environment.GetEnvironmentVariable("OCTOPUS_API_KEY");
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                await response.Send("Octopus Deploy API key has not been configured. Please set it as environment variable `OCTOPUS_API_KEY`");
            }
            else
            {
                var projectGroup = parameters[1];
                await response.Send($"Got it! Updating all projects in {projectGroup}.");

                var facade = new Facade(apiKey, new CachingTemplateRepository(new TeamCityArtifactTemplateRepository()));

                facade.UpdateAllProjects(projectGroup);

                await response.Send("Done!");
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:19,代码来源:UpdateProjectGroup.cs

示例13: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var apiKey = Environment.GetEnvironmentVariable("OCTOPUS_API_KEY");
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                await response.Send("Octopus Deploy API key has not been configured. Please set it as environment variable `OCTOPUS_API_KEY`");
            }
            else
            {
                var octopusProject = parameters[1];
                await response.Send($"Got it! Updating project {octopusProject}.");

                var facade = new Facade(apiKey, new TeamCityArtifactTemplateRepository());

                var url = facade.UpdateProject(octopusProject);

                await response.Send($"Done! Check out the updated project here {url}");
            }
        }
开发者ID:adamralph,项目名称:PBot,代码行数:19,代码来源:UpdateProject.cs

示例14: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var groupByCaretaker = Brain.Get<AvailableRepositories>()
                .GroupBy(r => r.Caretaker)
                .ToList();

            foreach (var caretaker in groupByCaretaker.Where(g => g.Key != null))
            {
                await response.Send($"*{caretaker.Key}*: {string.Join(", ", caretaker.Select(r => r.Name))}");
            }
            var upForGrabs = groupByCaretaker.SingleOrDefault(g => g.Key == null);

            if (upForGrabs != null)
            {
                await response.Send("Repos that is up for grabs:").IgnoreWaitContext();
                await response.Send(string.Join(", ", upForGrabs.Select(r => r.Name))).IgnoreWaitContext();
            }

            await response.Send("You can sign up using: `pbot register {your username} as caretaker for {name of the repo above}`").IgnoreWaitContext();
            await response.Send("Please read more about caretakers here - https://github.com/Particular/Housekeeping/wiki/Caretakers").IgnoreWaitContext();
        }
开发者ID:adamralph,项目名称:PBot,代码行数:21,代码来源:ListCaretakers.cs

示例15: Execute

        public override async Task Execute(string[] parameters, IResponse response)
        {
            var repoName = parameters[1];

            var allRepos = Brain.Get<AvailableRepositories>() ?? new AvailableRepositories();


            var toRemove = allRepos.SingleOrDefault(r => r.Name == repoName);

            if (toRemove == null)
            {
                await response.Send(repoName + " doesn't exists").IgnoreWaitContext();
                return;
            }

            allRepos.Remove(toRemove);

            await response.Send(repoName + " is now removed").IgnoreWaitContext();

            Brain.Set(allRepos);
        }
开发者ID:adamralph,项目名称:PBot,代码行数:21,代码来源:RemoveRepository.cs


注:本文中的IResponse.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。