Skip to content

Commit

Permalink
Add Files and Block to SlackBot SlackMessage
Browse files Browse the repository at this point in the history
- fixed: `SlackBot.CreateSlackMessage`: missing assignment of `Blocks`
- added: `SlackBot.CreateSlackMessage`: added assignment of `Files`
- added: `IMessage.Files` and `SlackMessage.Files` List

closes soxtoby issue #77
  • Loading branch information
FloH authored and soxtoby committed Mar 22, 2021
1 parent 08ae694 commit 66f4543
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions SlackNet.Bot/IMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public interface IMessage
string ThreadTs { get; set; }
DateTime ThreadTimestamp { get; }
IList<Attachment> Attachments { get; set; }

IList<File> Files { get; set; }

IList<Block> Blocks { get; set; }
bool IsInThread { get; }
bool MentionsBot { get; }
Expand Down
4 changes: 3 additions & 1 deletion SlackNet.Bot/SlackBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ private async Task<SlackMessage> CreateSlackMessage(MessageEvent message)
User = await user.ConfigureAwait(false),
Conversation = await conversation.ConfigureAwait(false),
Hub = await hub.ConfigureAwait(false),
Attachments = message.Attachments
Attachments = message.Attachments,
Files = message.Files,
Blocks = message.Blocks
};
}

Expand Down
5 changes: 4 additions & 1 deletion SlackNet.Bot/SlackMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class SlackMessage : IMessage
[JsonIgnore]
public DateTime ThreadTimestamp => Ts.ToDateTime().GetValueOrDefault();
public IList<Attachment> Attachments { get; set; } = new List<Attachment>();

public IList<File> Files { get; set; } = new List<File>();

public IList<Block> Blocks { get; set; } = new List<Block>();
public bool IsInThread => ThreadTs != null;

Expand All @@ -32,7 +35,7 @@ public class SlackMessage : IMessage
|| Text.IndexOf(_bot.Name, StringComparison.OrdinalIgnoreCase) >= 0
|| Conversation?.IsIm == true;

public Task ReplyWith(string text, bool createThread = false, CancellationToken? cancellationToken = null) =>
public Task ReplyWith(string text, bool createThread = false, CancellationToken? cancellationToken = null) =>
ReplyWith(new BotMessage { Text = text }, createThread, cancellationToken);

public async Task ReplyWith(Func<Task<BotMessage>> createReply, bool createThread = false, CancellationToken? cancellationToken = null)
Expand Down

0 comments on commit 66f4543

Please sign in to comment.