|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.ComponentModel; |
| 3 | +using System.IO; |
| 4 | +using System.Reflection.Metadata.Ecma335; |
| 5 | + |
| 6 | +namespace Amino.NET.Builders |
| 7 | +{ |
| 8 | + public class PostBuilder |
| 9 | + { |
| 10 | + public byte[] CoverImage { get; private set; } |
| 11 | + public byte[] BackgroundImage { get; private set; } |
| 12 | + public string BackgroundColor { get; private set; } = "#ffffff"; |
| 13 | + public string Content { get; set; } |
| 14 | + public string Title { get; set; } |
| 15 | + public List<(byte[], string?, string?)> MediaList { get; } = new List<(byte[], string?, string?)>(); |
| 16 | + public PostTypes PostType { get; set; } = PostTypes.Blog; |
| 17 | + public BackgroundTypes BackgroundType { get; set; } = BackgroundTypes.Color; |
| 18 | + public bool FansOnly { get; set; } |
| 19 | + |
| 20 | + |
| 21 | + public void WithCover(byte[] cover) |
| 22 | + { |
| 23 | + CoverImage = cover; |
| 24 | + } |
| 25 | + public void WithCover(string coverPath) |
| 26 | + { |
| 27 | + WithCover(File.ReadAllBytes(coverPath)); |
| 28 | + } |
| 29 | + |
| 30 | + public void WithBackgroundImage(byte[] media) |
| 31 | + { |
| 32 | + BackgroundImage = media; |
| 33 | + } |
| 34 | + |
| 35 | + public void WithBackgroundImage(string mediaPath) |
| 36 | + { |
| 37 | + WithBackgroundImage(File.ReadAllBytes(mediaPath)); |
| 38 | + } |
| 39 | + |
| 40 | + public void AddMedia(byte[] media, string mediaKey = null, string caption = null) |
| 41 | + { |
| 42 | + MediaList.Add((media, mediaKey, caption)); |
| 43 | + } |
| 44 | + |
| 45 | + public void AddMedia(string mediaPath, string mediaKey = null, string caption = null) |
| 46 | + { |
| 47 | + AddMedia(File.ReadAllBytes(mediaPath), mediaKey, caption); |
| 48 | + } |
| 49 | + |
| 50 | + public string EmbedImage(string mediaKey) => $"[IMG={mediaKey}]"; |
| 51 | + |
| 52 | + public enum PostTypes |
| 53 | + { |
| 54 | + Blog, |
| 55 | + Wiki |
| 56 | + } |
| 57 | + public enum BackgroundTypes |
| 58 | + { |
| 59 | + Color, |
| 60 | + Image |
| 61 | + } |
| 62 | + |
| 63 | + } |
| 64 | +} |
0 commit comments