예제 #1
0
파일: Vn.cs 프로젝트: Kadantte/Sanara
        public async Task Vndb(params string[] args)
        {
            Utilities.CheckAvailability(Context.Guild.Id, Program.Module.Vn);
            await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Vn);

            var result = await Vn.SearchVn(args, !((ITextChannel)Context.Channel).IsNsfw);

            switch (result.error)
            {
            case Error.Vn.Help:
                await ReplyAsync(Sentences.VndbHelp(Context.Guild.Id));

                break;

            case Error.Vn.NotFound:
                await ReplyAsync(Sentences.VndbNotFound(Context.Guild.Id));

                break;

            case Error.Vn.None:
                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = result.answer.originalTitle == null ? result.answer.title : result.answer.originalTitle + " (" + result.answer.title + ")",
                    Url         = result.answer.vnUrl,
                    ImageUrl    = result.answer.imageUrl,
                    Description = result.answer.description,
                    Color       = Color.Blue
                };
                embed.AddField(Sentences.AvailableEnglish(Context.Guild.Id), result.answer.isAvailableEnglish ? Base.Sentences.YesStr(Context.Guild.Id) : Base.Sentences.NoStr(Context.Guild.Id), true);
                embed.AddField(Sentences.AvailableWindows(Context.Guild.Id), result.answer.isAvailableWindows ? Base.Sentences.YesStr(Context.Guild.Id) : Base.Sentences.NoStr(Context.Guild.Id), true);
                string length = Sentences.Unknown(Context.Guild.Id);
                switch (result.answer.length)
                {
                case VisualNovelLength.VeryShort: length = Sentences.Hours(Context.Guild.Id, "< 2 "); break;

                case VisualNovelLength.Short: length = Sentences.Hours(Context.Guild.Id, "2 - 10 "); break;

                case VisualNovelLength.Medium: length = Sentences.Hours(Context.Guild.Id, "10 - 30 "); break;

                case VisualNovelLength.Long: length = Sentences.Hours(Context.Guild.Id, "30 - 50 "); break;

                case VisualNovelLength.VeryLong: length = Sentences.Hours(Context.Guild.Id, "> 50 "); break;
                }
                embed.AddField(Sentences.Length(Context.Guild.Id), length, true);
                embed.AddField(Sentences.VndbRating(Context.Guild.Id), result.answer.rating + " / 10", true);
                string releaseDate;
                if (result.answer.releaseYear == null)
                {
                    releaseDate = Sentences.Tba(Context.Guild.Id);
                }
                else
                {
                    releaseDate = result.answer.releaseYear.ToString();
                    if (result.answer.releaseMonth != null)
                    {
                        releaseDate = Utilities.AddZero(result.answer.releaseMonth.ToString()) + "/" + releaseDate;
                    }
                    if (result.answer.releaseDay != null)
                    {
                        releaseDate = Utilities.AddZero(result.answer.releaseDay.ToString()) + "/" + releaseDate;
                    }
                }
                embed.AddField(Sentences.ReleaseDate(Context.Guild.Id), releaseDate, true);
                await ReplyAsync("", false, embed.Build());

                break;

            default:
                throw new NotImplementedException();
            }
        }
예제 #2
0
        private Embed CreateEmbed(bool isAnime, Response.AnimeManga res)
        {
            string       fullName = res.name + ((res.alternativeTitles == null || res.alternativeTitles.Length == 0) ? ("") : (" (" + string.Join(", ", res.alternativeTitles) + ")"));
            EmbedBuilder embed    = new EmbedBuilder()
            {
                Title       = fullName.Length > 256 ? res.name : fullName,
                Url         = res.animeUrl,
                Color       = Color.Green,
                ImageUrl    = res.imageUrl,
                Description = res.synopsis
            };

            if (isAnime && res.episodeCount != null)
            {
                embed.AddField(Sentences.AnimeEpisodes(Context.Guild), res.episodeCount.Value + ((res.episodeLength != null) ? (" " + Sentences.AnimeLength(Context.Guild, res.episodeLength.Value)) : ("")), true);
            }
            if (res.rating != null)
            {
                embed.AddField(Sentences.AnimeRating(Context.Guild), res.rating.Value, true);
            }
            embed.AddField(Sentences.ReleaseDate(Context.Guild), ((res.startDate != null) ? res.startDate.Value.ToString(Base.Sentences.DateHourFormatShort(Context.Guild)) + " - " + ((res.endDate != null) ? (res.endDate.Value.ToString(Base.Sentences.DateHourFormatShort(Context.Guild))) : (Sentences.Unknown(Context.Guild))) : (Sentences.ToBeAnnounced(Context.Guild))), true);
            if (!string.IsNullOrEmpty(res.ageRating))
            {
                embed.AddField(Sentences.AnimeAudiance(Context.Guild), res.ageRating, true);
            }
            return(embed.Build());
        }
예제 #3
0
        public async Task Source(params string[] args)
        {
            Base.Utilities.CheckAvailability(Context.Guild.Id, Program.Module.AnimeManga);
            await p.DoAction(Context.User, Context.Guild.Id, Program.Module.AnimeManga);

            bool skipBeginning = false;

            if (Context.Message.Attachments.Count > 0)
            {
                args          = new[] { Context.Message.Attachments.ToArray()[0].Url };
                skipBeginning = true;
            }
            var result = await Features.Entertainment.AnimeManga.SearchSource(((ITextChannel)Context.Channel).IsNsfw, skipBeginning, Program.p.websiteUpload, Program.p.websiteUploadToken, args);

            switch (result.error)
            {
            case Error.Source.None:
                Color color;
                float certitude = result.answer.compatibility;
                if (certitude > 80f)
                {
                    color = Color.Green;
                }
                else if (certitude > 50)
                {
                    color = Color.Orange;
                }
                else
                {
                    color = Color.Red;
                }
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Color       = color,
                    Title       = result.answer.name,
                    Description = Sentences.Episode(Context.Guild.Id) + " " + (result.answer.episode == -1 ? Sentences.Unknown(Context.Guild.Id) : result.answer.episode.ToString()) + " " + Base.Sentences.AtStr(Context.Guild.Id) + " " + result.answer.at,
                    ImageUrl    = result.answer.imageUrl,
                    Footer      = new EmbedFooterBuilder
                    {
                        Text = Sentences.Certitude(Context.Guild.Id) + ": " + result.answer.compatibility.ToString("0.00") + "%"
                    }
                }.Build());

                break;

            case Error.Source.Help:
                await ReplyAsync(Sentences.SourceHelp(Context.Guild.Id));

                break;

            case Error.Source.NotFound:
                await ReplyAsync(Tools.Sentences.NotAnImage(Context.Guild.Id));

                break;

            case Error.Source.NotNsfw:
                await ReplyAsync(Base.Sentences.AnswerNsfw(Context.Guild.Id));

                break;

            case Error.Source.NotAnUrl:
                await ReplyAsync(Sentences.NotAnUrl(Context.Guild.Id));

                break;

            default:
                throw new NotImplementedException();
            }
        }