Beispiel #1
0
        public async Task GetPages_EnsureLinksAreCorrect()
        {
            var book = await HentaiClient.SearchBookAsync(125639);

            var actual = book.GetPages().ToList();

            var expected = new List <string>
            {
                "https://i.nhentai.net/galleries/779150/1.jpg",
                "https://i.nhentai.net/galleries/779150/2.png",
                "https://i.nhentai.net/galleries/779150/3.jpg",
                "https://i.nhentai.net/galleries/779150/4.jpg",
                "https://i.nhentai.net/galleries/779150/5.jpg",
                "https://i.nhentai.net/galleries/779150/6.jpg",
                "https://i.nhentai.net/galleries/779150/7.jpg",
                "https://i.nhentai.net/galleries/779150/8.jpg",
                "https://i.nhentai.net/galleries/779150/9.jpg",
                "https://i.nhentai.net/galleries/779150/10.jpg",
                "https://i.nhentai.net/galleries/779150/11.jpg",
                "https://i.nhentai.net/galleries/779150/12.jpg",
                "https://i.nhentai.net/galleries/779150/13.jpg",
                "https://i.nhentai.net/galleries/779150/14.jpg",
                "https://i.nhentai.net/galleries/779150/15.jpg",
                "https://i.nhentai.net/galleries/779150/16.jpg",
                "https://i.nhentai.net/galleries/779150/17.jpg",
                "https://i.nhentai.net/galleries/779150/18.jpg",
                "https://i.nhentai.net/galleries/779150/19.png",
                "https://i.nhentai.net/galleries/779150/20.jpg"
            };

            for (var i = 0; i < book.PagesCount - 1; i++)
            {
                Assert.AreEqual(actual[i], expected[i]);
            }
        }
Beispiel #2
0
        public async Task ReadingHen(int henId)
        {
            try
            {
                var book = await _hentai.SearchBookAsync(henId);

                var pages = book.GetPages().ToList();

                var paging = pages
                             .Select(result => new EmbedPage
                {
                    Title = $"**{book.Titles.Japanese}**",
                    AlternateAuthorTitle = "Nhentai",
                    AlternateAuthorIcon  = "https://i.4cdn.org/h/1605807858643.png",
                    ImageUrl             = result,
                    TimeStamp            = Now,
                    Url = $"https://nhentai.net/g/" + $"{book.Id}/"
                }).ToList();

                var options = new PaginatedAppearanceOptions
                {
                    Next    = new Emoji("▶️"),
                    Back    = new Emoji("◀️"),
                    Last    = new Emoji("↪️"),
                    First   = new Emoji("↩️"),
                    Timeout = TimeSpan.FromMinutes(15)
                };
                var paginatedMessage = new PaginatedMessage
                {
                    Pages          = paging,
                    Content        = "**Happy reading, this embed will expire in 15 minutes**",
                    Options        = options,
                    FooterOverride = new EmbedFooterBuilder().WithText($"Requested by {Context.User.Username}")
                                     .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl()),
                    TimeStamp = Now,
                    Color     = new Color(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor())
                };
                await PagedReplyAsync(paginatedMessage, new ReactionList());
            }
            catch
            {
                await Context.Channel.SendErrorAsync("Not found",
                                                     "Our engine can't find anything using your provided id");
            }
        }