From 206ed8a8feea4273fe992f5e42bdf7f44982d573 Mon Sep 17 00:00:00 2001 From: Simon Oxtoby Date: Wed, 1 Jan 2020 14:44:42 +1000 Subject: [PATCH] Adding rich text block --- SlackNet/Blocks/RichTextBlock.cs | 118 +++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 SlackNet/Blocks/RichTextBlock.cs diff --git a/SlackNet/Blocks/RichTextBlock.cs b/SlackNet/Blocks/RichTextBlock.cs new file mode 100644 index 0000000..151f3a2 --- /dev/null +++ b/SlackNet/Blocks/RichTextBlock.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SlackNet.Blocks +{ + [SlackType("rich_text")] + public class RichTextBlock : Block + { + public RichTextBlock() : base("rich_text") { } + + public IList Elements { get; set; } = new List(); + } + + public abstract class RichTextElement + { + public string Type { get; set; } + } + + public class RichTextSection : RichTextElement + { + public IList Elements { get; set; } = new List(); + } + + public abstract class RichTextSectionElement + { + public string Type { get; set; } + } + + [SlackType("text")] + public class RichTextText : RichTextSectionElement + { + public string Text { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("channel")] + public class RichTextChannel : RichTextSectionElement + { + public string ChannelId { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("user")] + public class RichTextUser + { + public string UserId { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("emoji")] + public class RichTextEmoji : RichTextSectionElement + { + public string Name { get; set; } + } + + [SlackType("link")] + public class RichTextLink : RichTextSectionElement + { + public string Url { get; set; } + public string Text { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("team")] + public class RichTextTeam : RichTextSectionElement + { + public string TeamId { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("usergroup")] + public class RichTextUserGroup : RichTextSectionElement + { + [JsonProperty("usergroup_id")] + public string UserGroupId { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("date")] + public class RichTextDate : RichTextSectionElement + { + public string Text { get; set; } + public string Timestamp { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + [SlackType("broadcast")] + public class RichTextBroadcast : RichTextSectionElement + { + public string Range { get; set; } + public RichTextStyle Style { get; set; } = new RichTextStyle(); + } + + public class RichTextList : RichTextElement + { + public IList Elements { get; set; } = new List(); + public string Style { get; set; } + public int Indent { get; set; } + } + + public class RichTextQuote : RichTextElement + { + public IList Elements { get; set; } = new List(); + } + + public class RichTextPreformatted : RichTextElement + { + public IList Elements { get; set; } = new List(); + } + + public class RichTextStyle + { + public bool Bold { get; set; } + public bool Code { get; set; } + public bool Italic { get; set; } + public bool Strike { get; set; } + } +} \ No newline at end of file