Skip to content

Commit

Permalink
Adding rich text block
Browse files Browse the repository at this point in the history
  • Loading branch information
soxtoby committed Jan 2, 2020
1 parent 4d26694 commit 206ed8a
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions SlackNet/Blocks/RichTextBlock.cs
Original file line number Diff line number Diff line change
@@ -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<RichTextElement> Elements { get; set; } = new List<RichTextElement>();
}

public abstract class RichTextElement
{
public string Type { get; set; }
}

public class RichTextSection : RichTextElement
{
public IList<RichTextSectionElement> Elements { get; set; } = new List<RichTextSectionElement>();
}

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<RichTextElement> Elements { get; set; } = new List<RichTextElement>();
public string Style { get; set; }
public int Indent { get; set; }
}

public class RichTextQuote : RichTextElement
{
public IList<RichTextSectionElement> Elements { get; set; } = new List<RichTextSectionElement>();
}

public class RichTextPreformatted : RichTextElement
{
public IList<RichTextSectionElement> Elements { get; set; } = new List<RichTextSectionElement>();
}

public class RichTextStyle
{
public bool Bold { get; set; }
public bool Code { get; set; }
public bool Italic { get; set; }
public bool Strike { get; set; }
}
}

0 comments on commit 206ed8a

Please sign in to comment.