示例#1
0
 private void assertSafePost(BooruSharp.Search.Post.SearchResult post)
 {
     if (!post.rating.Equals(BooruSharp.Search.Post.Rating.Safe))
     {
         throw new ArgumentOutOfRangeException("Booru post is not marked as safe.");
     }
 }
示例#2
0
 public void AddTag(int id, ABooru booru, BooruSharp.Search.Post.SearchResult post)
 {
     if (!_tags.ContainsKey(id))
     {
         _tags.Add(id, new Tuple <ABooru, BooruSharp.Search.Post.SearchResult>(booru, post));
     }
 }
示例#3
0
        public async static void SendPicture(Message mess, string search)
        {
            try
            {
                DanbooruDonmai booru = new DanbooruDonmai();
                BooruSharp.Search.Post.SearchResult result = await booru.GetRandomPostAsync(search);

                await BotMain.bot.SendPhotoAsync(mess.Chat.Id, new InputOnlineFile(result.FileUrl), $"Source: {result.FileUrl}");
            }
            catch (Exception e)
            {
                LogsLevels.LogError(e.ToString());
                SendPicture(mess, search);
            }
        }
示例#4
0
        public async Task <BooruSharp.Search.Post.SearchResult> Furrybooru(IUser usr, IGuild guild, ICommandContext context, string tag = "thighhighs")
        {
            BooruSharp.Booru.Furrybooru         Booru  = new BooruSharp.Booru.Furrybooru();
            BooruSharp.Search.Post.SearchResult result = new BooruSharp.Search.Post.SearchResult();
            try
            {
                result = await Booru.GetRandomPostAsync(tag.Split(','));

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                await SearchTag(context, tag);
            }

            return(result);
        }
示例#5
0
        private Task commonBooruResponse(BooruSharp.Search.Post.SearchResult post)
        {
            var embedBuilder = new EmbedBuilder();

            embedBuilder.WithTitle(post.id.ToString());
            embedBuilder.WithDescription(getDescription(post.score, post.rating, post.tags));
            embedBuilder.WithColor(Color.Gold);
            string postUrl = post.postUrl.AbsoluteUri.ToString();

            embedBuilder.WithUrl(postUrl);
            string imageUrl = post.fileUrl.AbsoluteUri.ToString();

            embedBuilder.WithImageUrl(imageUrl);

            if (post.creation != null)
            {
                DateTimeOffset time = new DateTimeOffset((DateTime)post.creation);
                embedBuilder.WithTimestamp(time);
            }

            return(Context.Channel.SendMessageAsync(embed: embedBuilder.Build()));
        }