public void LoadBuildAssetMainMenuData()
    {
        galleryelementlist = new List <GalleryElement> ()
        {
        };
        //galleryelementlist.Clear ();
        for (int i = 0; i < maindatabase.DatabaseMapList.Count; i++)
        {
            currentelementid = i;
            maindatabase.DatabaseMapList [i].RealID = i;
            currentelementname   = maindatabase.DatabaseMapList[i].RealID + " - " + maindatabase.DatabaseMapList [i].Map[0].Name;
            currentelementsprite = Resources.Load <Sprite> ("");

            currentgalleryelement = new GalleryElement(currentelementid, currentelementname, currentelementsprite);
            galleryelementlist.Add(currentgalleryelement);
        }


        List <string> currentoptiontext = new List <string>()
        {
            "Edit Map", "Delete Map", "", "", ""
        };

        gallery = new GalleryUI(0, "Build Map Menu", true, "New Map", 2, currentoptiontext, galleryelementlist);
        menuuimanager.UpdateMenu();
    }
示例#2
0
        public async Task Hentai([Remainder] string tags)
        {
            GalleryElement qq = await NHentaiService.getBook(tags);

            Console.WriteLine(qq.numPages);
            var paginator = new LazyPaginatorBuilder()
                            .WithUsers(Context.User)
                            .WithPageFactory(PageFactory)
                            .WithMaxPageIndex(int.Parse(qq.numPages.ToString()))
                            .WithFooter(PaginatorFooter.PageNumber | PaginatorFooter.Users)
                            .WithDefaultEmotes()
                            .Build();

            Console.WriteLine(qq.cover.imageUrl);
            //await Context.Channel.SendMessageAsync(stuff.value[0].thumbnailUrl.ToString());
            await Interactivity.SendPaginatorAsync(paginator, Context.Channel, TimeSpan.FromMinutes(2));

            Task <PageBuilder> PageFactory(int page)
            {
                return(Task.FromResult(new PageBuilder()
                                       //.WithText((page + 1).ToString())
                                       .WithTitle(qq.prettyTitle + $" Page {page + 1}")
                                       .WithImageUrl(qq.pages[page].imageUrl.ToString())
                                       .WithColor(System.Drawing.Color.FromArgb(page * 400))));
            }
        }
 public static void SetElement(GalleryElement el)
 {
     if (isNullInstance)
     {
         return;
     }
     instance.element = el;
 }
示例#4
0
    public void AddGame()
    {
        int    galleryid     = galleryelementlist.Count;
        Sprite newgamesprite = Resources.Load <Sprite> ("");

        currentgalleryelement = new GalleryElement(galleryid, "New Game", newgamesprite);
        galleryelementlist.Add(currentgalleryelement);
    }
示例#5
0
 private Embed FormatDoujinshi(GalleryElement result)
 {
     return(new EmbedBuilder
     {
         Color = new Color(255, 20, 147),
         Description = string.Join(", ", result.tags.Select(x => x.name)),
         Title = result.prettyTitle,
         Url = result.url.AbsoluteUri,
         ImageUrl = result.pages[0].imageUrl.AbsoluteUri,
         Footer = new EmbedFooterBuilder
         {
             Text = $"Do the 'Download doujinshi' command with the id '{result.id}' to download the doujinshi."
         }
     }.Build());
 }
示例#6
0
    public void LoadBuildAssetMainMenuData()
    {
        galleryelementlist = new List <GalleryElement> ()
        {
        };
        List <string> currentoptiontext = new List <string>()
        {
            "Build Map", "Build Template", "Map Type", "", ""
        };

        Sprite gallerythumbnail1 = Resources.Load <Sprite> ("");

        currentgalleryelement = new GalleryElement(0, "Map", gallerythumbnail1);
        galleryelementlist.Add(currentgalleryelement);
        //currentgalleryelement = new GalleryElement (1,"game 2",gallerythumbnail2);
        //galleryelementlist.Add (currentgalleryelement);


        buildassetselectgallery = new GalleryUI(0, "Build Asset Menu", false, "New Asset", 3, currentoptiontext, galleryelementlist);
    }
示例#7
0
    private void LoadSelectGameMenuData()
    {
        galleryelementlist = new List <GalleryElement> ()
        {
        };
        List <string> currentoptiontext = new List <string>()
        {
            "Play Game", "Game Detail", "Build Game", "Duplicate Game", "Delete Game"
        };

        Sprite gallerythumbnail1 = Resources.Load <Sprite> ("Sprites/Game/Thumbnail/placeholder1");
        Sprite gallerythumbnail2 = Resources.Load <Sprite> ("Sprites/Game/Thumbnail/placeholder2");

        currentgalleryelement = new GalleryElement(0, "game 1", gallerythumbnail1);
        galleryelementlist.Add(currentgalleryelement);
        currentgalleryelement = new GalleryElement(1, "game 2", gallerythumbnail2);
        galleryelementlist.Add(currentgalleryelement);


        gameselectmenugallery = new GalleryUI(0, "Game Gallery", true, "New Game", 5, currentoptiontext, galleryelementlist);
    }
示例#8
0
        public async Task Command()
        {
            bool isBlacklisted     = true;
            var  wildcardBlacklist = new[]
            {
                "loli",
                "con",
                "shota",
                "rape"
            };

            string[] tags = new[]
            {
                SearchClient.GetExcludeTag("rape"),
                SearchClient.GetExcludeTag("loli"),
                SearchClient.GetExcludeTag("lolicon"),
                SearchClient.GetExcludeTag("furry"),
                SearchClient.GetExcludeTag("vore"),
                SearchClient.GetExcludeTag("gore"),
                SearchClient.GetExcludeTag("shotacon")
            };

            while (isBlacklisted)
            {
                var r = new Random();

                SearchResult result = await SearchClient.SearchWithTagsAsync(tags.ToArray());

                int page = r.Next(0, result.numPages) + 1; // Page count begins at 1.

                result = await SearchClient.SearchWithTagsAsync(tags.ToArray(), page);

                GalleryElement selection = result.elements[r.Next(0, result.elements.Length)];

                string tagString = selection.tags.Aggregate("", (current, tag) => current + $"`{tag.name}`, ");
                tagString = tagString.Substring(0, tagString.Length - 2);

                if (wildcardBlacklist.Any(tagString.Contains))
                {
                    continue;
                }

                isBlacklisted = false;

                var embed = new KaguyaEmbedBuilder
                {
                    Title       = $"{selection.englishTitle}",
                    Description = $"[[Source]]({selection.url})",
                    Fields      = new List <EmbedFieldBuilder>()
                    {
                        new EmbedFieldBuilder
                        {
                            Name  = "Favorites",
                            Value = selection.numFavorites.ToString("N0")
                        },
                        new EmbedFieldBuilder
                        {
                            Name  = "Date Uploaded",
                            Value = selection.uploadDate.Humanize()
                        },
                        new EmbedFieldBuilder
                        {
                            Name  = "Pages",
                            Value = selection.numPages
                        },
                        new EmbedFieldBuilder
                        {
                            Name  = "Tags",
                            Value = tagString
                        }
                    },
                    ImageUrl = selection.thumbnail.imageUrl.ToString()
                };

                await ReplyAsync(embed : embed.Build());
            }
        }
示例#9
0
        public async Task NonBooru(CommandContext ctx, [Description("Source to select image from (ls for a list)")]
                                   DoujinEnumConv.DoujinEnum source,
                                   [Description("Tags for image selection")]
                                   params string[] tags)
        {
            if (ctx.Channel.Get(ConfigManager.Enabled)
                .And(ctx.Channel.GetMethodEnabled()))
            {
                await ctx.TriggerTypingAsync();

                if (ctx.Channel.GetEvaluatedNsfw())
                {
                    using WebClient wClient = new WebClient();
                    string val = Program.Rnd.Next(10000, 99999).ToString();
                    string html;
                    string url;
                    switch (source)
                    {
                    case DoujinEnumConv.DoujinEnum.Nhentai:
                    {
                        NHentaiSharp.Search.SearchResult result;
                        try
                        {
                            result = await(tags.Length == 0
                                    ? SearchClient.SearchAsync()
                                    : SearchClient.SearchWithTagsAsync(tags));
                        }
                        catch (InvalidArgumentException)
                        {
                            await ctx.RespondAsync("Not found");

                            break;
                        }
                        int page = Program.Rnd.Next(0, result.numPages) + 1;
                        result = await(tags.Length == 0
                                ? SearchClient.SearchAsync(page)
                                : SearchClient.SearchWithTagsAsync(tags, page));
                        GalleryElement doujinshi = result.elements[Program.Rnd.Next(0, result.elements.Length)];
                        await ctx.RespondWithFileAsync($"{val}_img.jpg",
                                                       wClient.OpenRead(doujinshi.cover.imageUrl.Unshorten()), embed : new DiscordEmbedBuilder
                            {
                                Description = $"Tags: {string.Join(", ", doujinshi.tags.Select(s => s.name))}",
                                Title       = $"{doujinshi.japaneseTitle} ({doujinshi.prettyTitle})",
                                Url         = doujinshi.url.ToString(),
                                Footer      = new DiscordEmbedBuilder.EmbedFooter
                                {
                                    Text = "Click on the title to access the doujin page."
                                }
                            }.Build());

                        break;
                    }

                    case DoujinEnumConv.DoujinEnum.EHentai:
                        url =
                            $"https://e-hentai.org/?f_cats=959&f_search={Uri.EscapeDataString(string.Join(" ", tags))}";
                        int           randomDoujinshi;
                        string        imageUrl;
                        List <string> allTags = new List <string>();
                        string        finalUrl;
                        using (HttpClient hc = new HttpClient())
                        {
                            html = await hc.GetStringAsync(url);

                            Match m = Regex.Match(html, "Showing ([0-9,]+) result");
                            if (!m.Success)
                            {
                                await ctx.RespondAsync("Not found");

                                break;
                            }
                            randomDoujinshi = Program.Rnd.Next(0, int.Parse(m.Groups[1].Value.Replace(",", "")));
                            html            = await hc.GetStringAsync($"{url}&page={randomDoujinshi / 25}");

                            finalUrl =
                                Regex.Matches(html, "<a href=\"(https:\\/\\/e-hentai\\.org\\/g\\/[^\"]+)\"")[
                                    randomDoujinshi % 25].Groups[1].Value;
                            html = await hc.GetStringAsync(finalUrl);

                            string htmlTags = html.Split(new[] { "taglist" }, StringSplitOptions.None)[1]
                                              .Split(new[] { "Showing" }, StringSplitOptions.None)[0];
                            foreach (Match match in Regex.Matches(htmlTags, ">([^<]+)<\\/a><\\/div>"))
                            {
                                allTags.Add(match.Groups[1].Value);
                            }
                            string htmlCover = await hc.GetStringAsync(Regex
                                                                       .Match(html, "<a href=\"([^\"]+)\"><img alt=\"0*1\"").Groups[1].Value);

                            imageUrl = Regex.Match(htmlCover, "<img id=\"img\" src=\"([^\"]+)\"").Groups[1].Value;
                        }
                        await ctx.RespondWithFileAsync($"{val}_img.jpg",
                                                       wClient.OpenRead(imageUrl), embed : new DiscordEmbedBuilder
                        {
                            Description = $"Tags: {string.Join(", ", allTags.ToArray())}",
                            Title       = HttpUtility.HtmlDecode(Regex
                                                                 .Match(html, "<title>(.+) - E-Hentai Galleries<\\/title>").Groups[1].Value),
                            Url    = finalUrl,
                            Footer = new DiscordEmbedBuilder.EmbedFooter
                            {
                                Text = "Click on the title to access the doujin page."
                            }
                        }.Build());

                        break;

                    /*case DoujinEnumConv.DoujinEnum.JavMost:
                     *  string tag = tags.Length > 0 ? string.Join(" ", tags).ToLower() : "";
                     *  if (tags.Length > 0 && !JavMostCategories.Contains(tag))
                     *  {
                     *      await ctx.RespondAsync("Not found");
                     *      break;
                     *  }
                     *  if (tag == "")
                     *      tag = "all";
                     *  int perPage;
                     *  int total;
                     *  url = $"https://www5.javmost.com/category/{tag}";
                     *  using (HttpClient hc = new HttpClient())
                     *  {
                     *      html = await hc.GetStringAsync(url);
                     *      perPage = Regex.Matches(html, "<!-- begin card -->").Count;
                     *      total = int.Parse(Regex.Match(html,
                     *              "<input type=\"hidden\" id=\"page_total\" value=\"([0-9]+)\" \\/>").Groups[1]
                     *          .Value);
                     *  }
                     *  Match videoMatch;
                     *  string[] videoTags = null;
                     *  string previewUrl = "";
                     *  int nbTry = 0;
                     *  do
                     *  {
                     *      int video = Program.Rnd.Next(0, total);
                     *      int pageNumber = video / perPage;
                     *      int pageIndex = video % perPage;
                     *      if (pageNumber > 0)
                     *      {
                     *          using HttpClient hc = new HttpClient();
                     *          html = await hc.GetStringAsync($"{url}/page/{pageNumber + 1}");
                     *      }
                     *      int index = pageIndex + 1;
                     *      string[] arr = html.Split(new[] {"<!-- begin card -->"}, StringSplitOptions.None);
                     *      if (index >= arr.Length)
                     *      {
                     *          videoMatch = Regex.Match("", "a");
                     *          continue;
                     *      }
                     *      string videoHtml = arr[index];
                     *      videoMatch = Regex.Match(videoHtml,
                     *          "<a href=\"(https:\\/\\/www5\\.javmost\\.com\\/([^\\/]+)\\/)\"");
                     *      previewUrl = Regex.Match(videoHtml, "data-src=\"([^\"]+)\"").Groups[1].Value;
                     *      if (previewUrl.StartsWith("//"))
                     *          previewUrl = $"https:{previewUrl}";
                     *      videoTags = Regex
                     *          .Matches(videoHtml,
                     *              "<a href=\"https:\\/\\/www5\\.javmost\\.com\\/category\\/([^\\/]+)\\/\"")
                     *          .Select(x => x.Groups[1].Value).ToArray();
                     *      nbTry++;
                     *      if (nbTry <= 10) continue;
                     *      await ctx.RespondAsync("Not found");
                     *      break;
                     *  } while (!videoMatch.Success);
                     *  await ctx.RespondWithFileAsync($"{val}_img.jpg",
                     *      wClient.OpenRead(previewUrl), embed: new DiscordEmbedBuilder
                     *      {
                     *          Description =
                     *              $"Tags: {string.Join(", ", videoTags ?? throw new Exception("Unexpected internal val"))}",
                     *          Title = videoMatch.Groups[2].Value,
                     *          Url = videoMatch.Groups[1].Value,
                     *          Footer = new DiscordEmbedBuilder.EmbedFooter
                     *          {
                     *              Text = "Click on the title to access the doujin page."
                     *          }
                     *      }.Build());
                     *  break;*/
                    case DoujinEnumConv.DoujinEnum.Ls:
                        await ctx.RespondAsync(string.Join("; ", Enum.GetNames(typeof(DoujinEnumConv.DoujinEnum))));

                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(source), source, null);
                    }
                }
                else
                {
                    await ctx.RespondAsync("NSFW Channels only!");
                }
            }
        }
示例#10
0
        private List <Element> mapImages(List <Images> list1, List <ImageListcs> list2, List <List <Images> > galleries)
        {
            List <Element>     elements    = new List <Element>();
            List <ImageListcs> tempGallery = new List <ImageListcs>();

            foreach (var img in list2)
            {
                if (img.gallery)
                {
                    tempGallery.Add(img);
                }
            }

            list2.RemoveAll(img => img.gallery);

            //map gallery data on service with gallery info send via blog creation
            GalleryElement g = new GalleryElement();

            g.Images = new List <Images>();
            foreach (var img in tempGallery)
            {
                foreach (var gallery in galleries)
                {
                    var match = gallery.Find(x => x.name.Equals(img.name));
                    if (match == null)
                    {
                        continue;
                    }
                    g.Images.Add(new Images {
                        base64 = match.base64
                    });
                    if (g.position == 0)
                    {
                        g.position = img.position;
                    }
                    g.ClassName = img.galleryName;
                }
            }
            if (g.Images.Count > 0)
            {
                elements.Add(g);
            }

            //map images, if available
            foreach (var img in list2)
            {
                var imgElement = new ImageElement();
                list1.ForEach(x => { if (x.name.Equals(img.name))
                                     {
                                         imgElement.base64 = x.base64; imgElement.position = img.position;
                                     }
                              });
                if (imgElement != null)
                {
                    elements.Add(imgElement);
                }
            }


            return(elements);
        }