예제 #1
0
        public async Task ListPlugins([FromBody] TenantMessage tenantMessage, CancellationToken cancellationToken)
        {
            var pluginInformations = await _pluginApi.GetPluginsAsync(cancellationToken).ConfigureAwait(false);

            var stringBuilder = pluginInformations
                                .OrderBy(i => i.Id.Value)
                                .Aggregate(new StringBuilder(), (s, i) => s.AppendLine($"{i.Id} - {i.Description} v{i.Version}"));
            await _messageApi.ReplyToAsync(tenantMessage, stringBuilder.ToString(), cancellationToken).ConfigureAwait(false);
        }
예제 #2
0
        public async Task GetReleases([FromBody] TenantMessage tenantMessage, CancellationToken cancellationToken)
        {
            var match = ListReleasesRegex.Match(tenantMessage.Text);
            var owner = match.Groups["owner"].Value.Trim();
            var repo  = match.Groups["repo"].Value.Trim();

            var releases = await _gitHubService.GetAllReleasesAsync(owner, repo, cancellationToken).ConfigureAwait(false);

            if (!releases.Any())
            {
                await _messageApi.ReplyToAsync(tenantMessage, $"There's no releases for {owner}/{repo}", cancellationToken).ConfigureAwait(false);

                return;
            }

            var text = releases.Aggregate(
                new StringBuilder().AppendLine($"Releases for {owner}/{repo}"),
                (b, r) => b.AppendLine($"- {r.Name} [{r.TagName}]"))
                       .ToString();

            await _messageApi.ReplyToAsync(tenantMessage, text, cancellationToken).ConfigureAwait(false);
        }