示例#1
0
        private async Task RunNsfwAsync <T>(IContext e)
            where T : BooruPost, ILinkable
        {
            try
            {
                ILinkable s = await ImageboardProviderPool.GetProvider <T>()
                              .GetPostAsync(e.GetArgumentPack().Pack.TakeAll(), ImageRating.EXPLICIT);

                if (!IsValid(s))
                {
                    throw new DataNotFoundException();
                }

                await CreateEmbed(s)
                .QueueAsync(e, e.GetChannel());
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new DataNotFoundException();
            }
            catch (Exception ex)
            {
                if (!(ex is LocalizedException))
                {
                    await e.ErrorEmbed("Too many tags for this system. sorry :(")
                    .ToEmbed()
                    .QueueAsync(e, e.GetChannel());
                }
                throw;
            }

            await UnlockLewdAchievementAsync(e, e.GetService <AchievementService>());
        }
示例#2
0
        public async Task DoSafe(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            ILinkable s = null;

            if (e.arguments.ToLower().StartsWith("use"))
            {
                string[] a = e.arguments.Split(' ');
                e.arguments = e.arguments.Substring(a[0].Length);
                switch (a[0].Split(':')[1].ToLower())
                {
                case "safebooru":
                {
                    s = ImageboardProviderPool.GetProvider <SafebooruPost>().GetPost(e.arguments, ImageboardRating.SAFE);
                }
                break;

                case "gelbooru":
                {
                    s = ImageboardProviderPool.GetProvider <GelbooruPost>().GetPost(e.arguments, ImageboardRating.SAFE);
                }
                break;

                case "konachan":
                {
                    s = ImageboardProviderPool.GetProvider <KonachanPost>().GetPost(e.arguments, ImageboardRating.SAFE);
                }
                break;

                case "e621":
                {
                    s = ImageboardProviderPool.GetProvider <E621Post>().GetPost(e.arguments, ImageboardRating.SAFE);
                }
                break;

                default:
                {
                    await e.Channel.SendMessage("I do not support this image host :(");
                }
                break;
                }
            }
            else
            {
                s = ImageboardProviderPool.GetProvider <SafebooruPost>().GetPost(e.arguments, ImageboardRating.SAFE);
            }

            if (s == null)
            {
                await Utils.ErrorEmbed(locale, "We couldn't find an image with these tags!").SendToChannel(e.Channel);

                return;
            }

            await e.Channel.SendMessage(s.Url);
        }
示例#3
0
        public async Task RunYandere(EventContext e)
        {
            ILinkable s = ImageboardProviderPool.GetProvider <YanderePost>().GetPost(e.arguments, ImageboardRating.EXPLICIT);

            if (!IsValid(s))
            {
                e.ErrorEmbed("Couldn't find anything with these tags!")
                .QueueToChannel(e.Channel);
                return;
            }

            CreateEmbed(s).QueueToChannel(e.Channel);
        }
示例#4
0
文件: NsfwModule.cs 项目: drogs/Miki
        public async Task RunYandere(EventContext e)
        {
            ILinkable s = ImageboardProviderPool.GetProvider <YanderePost>().GetPost(e.arguments, ImageboardRating.EXPLICIT);

            if (s == null)
            {
                await Utils.ErrorEmbed(Locale.GetEntity(e.Channel.Id), "Couldn't find anything with these tags!")
                .SendToChannel(e.Channel);
            }

            await Utils.Embed
            .SetTitle("YANDE.RE")
            .SetImageUrl(s.Url)
            .SendToChannel(e.Channel.Id);
        }
示例#5
0
        public async Task RunYandere(EventContext e)
        {
            ILinkable s = ImageboardProviderPool.GetProvider <YanderePost>().GetPost(e.arguments, ImageboardRating.EXPLICIT);

            if (!IsValid(s))
            {
                await Utils.ErrorEmbed(Locale.GetEntity(e.Channel.Id), "Couldn't find anything with these tags!")
                .SendToChannel(e.Channel);

                return;
            }

            await CreateEmbed(s)
            .SendToChannel(e.Channel);
        }
示例#6
0
        public async Task RunYandere(EventContext e)
        {
            try
            {
                ILinkable s = await ImageboardProviderPool.GetProvider <YanderePost>().GetPostAsync(e.Arguments.ToString(), ImageboardRating.EXPLICIT);

                if (!IsValid(s))
                {
                    e.ErrorEmbed("Couldn't find anything with these tags!")
                    .ToEmbed().QueueToChannel(e.Channel);
                    return;
                }

                CreateEmbed(s).QueueToChannel(e.Channel);
            }
            catch (Exception ex)
            {
                e.ErrorEmbed("Too many tags for this system. sorry :(")
                .ToEmbed().QueueToChannel(e.Channel);
            }
        }
示例#7
0
        public async Task RunE621(EventContext e)
        {
            try
            {
                ILinkable s = await ImageboardProviderPool.GetProvider <E621Post>().GetPostAsync(e.Arguments.Pack.TakeAll(), ImageboardRating.EXPLICIT);

                if (!IsValid(s))
                {
                    await e.ErrorEmbed("Couldn't find anything with these tags!")
                    .ToEmbed().QueueToChannelAsync(e.Channel);

                    return;
                }

                await CreateEmbed(s)
                .QueueToChannelAsync(e.Channel);
            }
            catch
            {
                await e.ErrorEmbed("Too many tags for this system. sorry :(")
                .ToEmbed().QueueToChannelAsync(e.Channel);
            }
        }
示例#8
0
        public async Task DoSafe(EventContext e)
        {
            ILinkable s = null;

            ArgObject arg = e.Arguments.FirstOrDefault();

            if (arg != null)
            {
                string useArg = arg.Argument;

                if (useArg.ToLower().StartsWith("use"))
                {
                    arg = arg.Next();

                    switch (useArg.Split(':')[1].ToLower())
                    {
                    case "safebooru":
                    {
                        s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(arg?.TakeUntilEnd().Argument, ImageboardRating.SAFE);
                    }
                    break;

                    case "gelbooru":
                    {
                        s = await ImageboardProviderPool.GetProvider <GelbooruPost>().GetPostAsync(arg?.TakeUntilEnd().Argument, ImageboardRating.SAFE);
                    }
                    break;

                    case "konachan":
                    {
                        s = await ImageboardProviderPool.GetProvider <KonachanPost>().GetPostAsync(arg?.TakeUntilEnd().Argument, ImageboardRating.SAFE);
                    }
                    break;

                    case "e621":
                    {
                        s = await ImageboardProviderPool.GetProvider <E621Post>().GetPostAsync(arg?.TakeUntilEnd().Argument, ImageboardRating.SAFE);
                    }
                    break;

                    default:
                    {
                        e.Channel.QueueMessageAsync("I do not support this image host :(");
                    }
                    break;
                    }
                }
                else
                {
                    s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(e.Arguments.Join()?.Argument ?? "", ImageboardRating.SAFE);
                }
            }
            else
            {
                s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(e.Arguments.Join()?.Argument ?? "", ImageboardRating.SAFE);
            }

            if (s == null)
            {
                e.ErrorEmbed("We couldn't find an image with these tags!").ToEmbed().QueueToChannel(e.Channel);
                return;
            }

            e.Channel.QueueMessageAsync(s.Url);
        }
示例#9
0
        public async Task DoSafe(ICommandContext e)
        {
            ILinkable s = null;

            if (e.Arguments.Take(out string useArg))
            {
                string tags = e.Arguments.Pack.TakeAll();
                if (useArg.ToLower().StartsWith("use"))
                {
                    switch (useArg.Split(':')[1].ToLower())
                    {
                    case "safebooru":
                    {
                        s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(tags, ImageRating.SAFE);
                    }
                    break;

                    case "gelbooru":
                    {
                        s = await ImageboardProviderPool.GetProvider <GelbooruPost>().GetPostAsync(tags, ImageRating.SAFE);
                    }
                    break;

                    case "konachan":
                    {
                        s = await ImageboardProviderPool.GetProvider <KonachanPost>().GetPostAsync(tags, ImageRating.SAFE);
                    }
                    break;

                    case "e621":
                    {
                        s = await ImageboardProviderPool.GetProvider <E621Post>().GetPostAsync(tags, ImageRating.SAFE);
                    }
                    break;

                    default:
                    {
                        e.Channel.QueueMessage("I do not support this image host :(");
                    }
                    break;
                    }
                }
                else
                {
                    s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(tags, ImageRating.SAFE);
                }
            }
            else
            {
                string tags = e.Arguments.Pack.TakeAll();
                s = await ImageboardProviderPool.GetProvider <SafebooruPost>().GetPostAsync(tags, ImageRating.SAFE);
            }

            if (s == null)
            {
                await e.ErrorEmbed("We couldn't find an image with these tags!")
                .ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }

            e.Channel.QueueMessage(s.Url);
        }