Exemplo n.º 1
0
        public async Task PublishNewAsync(AnalyzeResult anime, AnimeInfoResult animeInfo)
        {
            var message = new StringBuilder($"*{anime.AnimeTitle}* ha comenzado a emitirse.\n\n");

            if (!string.IsNullOrWhiteSpace(animeInfo.Description))
            {
                if (animeInfo.Description.Length > 120)
                {
                    animeInfo.Description = string.Concat(animeInfo.Description.Remove(120), $"... [Leer más]({anime.GetAnimeProfileUrl()})");
                }

                message.Append($"{animeInfo.Description} \n\n");
            }


            if (!string.IsNullOrWhiteSpace(anime.AnimeLink))
            {
                message.Append($"[Ver capítulo]({anime.AnimeLink}) \n\n");
            }

            if (!(animeInfo.Genres is null) && animeInfo.Genres.Any())
            {
                var genres = string.Join(' ', animeInfo.Genres.Select(g => $"#{g.Replace(" ", "")}")).ToString();
                message.Append(genres);
            }

            await _publishService.PublishAsync(message.ToString());
        }