File tree Expand file tree Collapse file tree 5 files changed +64
-1
lines changed
src/Slackbot.Net.SlackClients.Http
Models/Requests/ChatPostEphemeral
test/Slackbot.Net.SlackClients.Http.Tests Expand file tree Collapse file tree 5 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 1+ using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostEphemeral ;
12using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostMessage ;
23using Slackbot . Net . SlackClients . Http . Models . Requests . FileUpload ;
34using Slackbot . Net . SlackClients . Http . Models . Requests . ViewPublish ;
@@ -29,6 +30,12 @@ public interface ISlackClient
2930 /// </summary>
3031 /// <remarks>https://api.slack.com/methods/chat.postMessage</remarks>
3132 Task < ChatPostMessageResponse > ChatPostMessage ( ChatPostMessageRequest postMessage ) ;
33+
34+ /// <summary>
35+ /// Scopes required: `chat:write`
36+ /// </summary>
37+ /// <remarks>https://api.slack.com/methods/chat.postEphemeral</remarks>
38+ Task < ChatPostMessageResponse > ChatPostEphemeralMessage ( ChatPostEphemeralMessageRequest postMessage ) ;
3239
3340 /// <summary>
3441 /// Scopes required: no scopes required
Original file line number Diff line number Diff line change 1+ using Slackbot . Net . Models . BlockKit ;
2+
3+ namespace Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostEphemeral ;
4+
5+ public class ChatPostEphemeralMessageRequest
6+ {
7+ public string Channel { get ; set ; }
8+ public string Text { get ; set ; }
9+ public string User { get ; set ; }
10+
11+ public bool Link_Names { get ; set ; } = true ;
12+ public string thread_ts { get ; set ; }
13+ public IBlock [ ] Blocks { get ; set ; }
14+ }
Original file line number Diff line number Diff line change 11using Microsoft . Extensions . Logging ;
22using Slackbot . Net . SlackClients . Http . Extensions ;
3+ using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostEphemeral ;
34using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostMessage ;
45using Slackbot . Net . SlackClients . Http . Models . Requests . FileUpload ;
56using Slackbot . Net . SlackClients . Http . Models . Requests . ViewPublish ;
@@ -47,6 +48,12 @@ public async Task<ChatPostMessageResponse> ChatPostMessage(ChatPostMessageReques
4748 return await _client . PostJson < ChatPostMessageResponse > ( postMessage , "chat.postMessage" , s => _logger . LogTrace ( s ) ) ;
4849 }
4950
51+ /// <inheritdoc/>
52+ public async Task < ChatPostMessageResponse > ChatPostEphemeralMessage ( ChatPostEphemeralMessageRequest postMessage )
53+ {
54+ return await _client . PostJson < ChatPostMessageResponse > ( postMessage , "chat.postEphemeral" , s => _logger . LogTrace ( s ) ) ;
55+ }
56+
5057 /// <inheritdoc/>
5158 public async Task < ChatGetPermalinkResponse > ChatGetPermalink ( string channel , string message_ts )
5259 {
Original file line number Diff line number Diff line change 11using System . Collections ;
22using Slackbot . Net . Models . BlockKit ;
33using Slackbot . Net . SlackClients . Http . Exceptions ;
4+ using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostEphemeral ;
45using Slackbot . Net . SlackClients . Http . Models . Requests . ChatPostMessage ;
56using Slackbot . Net . Tests . Helpers ;
67
@@ -33,6 +34,40 @@ public async Task PostWorks()
3334 Assert . True ( response . Ok ) ;
3435 }
3536
37+ [ Fact ]
38+ public async Task PostEphemeralWorks ( )
39+ {
40+ var msg = new ChatPostEphemeralMessageRequest ( )
41+ {
42+ Channel = Channel ,
43+ Text = Text ,
44+ User = "U0EBWMGG4"
45+ } ;
46+ var response = await SlackClient . ChatPostEphemeralMessage ( msg ) ;
47+ Assert . True ( response . Ok ) ;
48+ }
49+
50+ [ Fact ]
51+ public async Task PostEphemeralThreadWorks ( )
52+ {
53+ var initMsg = await SlackClient . ChatPostMessage ( Channel , "Some thread starting text" ) ;
54+ var reply = await SlackClient . ChatPostMessage ( new ChatPostMessageRequest
55+ {
56+ Channel = Channel ,
57+ Text = "A threaded reply " ,
58+ thread_ts = initMsg . ts ,
59+ } ) ;
60+ var msg = new ChatPostEphemeralMessageRequest ( )
61+ {
62+ Channel = Channel ,
63+ Text = "This is ephemeral to johnkors" ,
64+ User = "U0EBWMGG4" ,
65+ thread_ts = reply . ts
66+ } ;
67+ var response = await SlackClient . ChatPostEphemeralMessage ( msg ) ;
68+ Assert . True ( response . Ok ) ;
69+ }
70+
3671 [ Fact ]
3772 public async Task PostWithBroadCastWorks ( )
3873 {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public Setup(ITestOutputHelper helper)
3434 SearchClient = provider . GetService < ISearchClient > ( ) ;
3535 SlackClient = provider . GetService < ISlackClient > ( ) ;
3636 SlackOAuthClient = provider . GetService < ISlackOAuthAccessClient > ( ) ;
37- Channel = "#testss " ;
37+ Channel = "#test " ;
3838 Text = "Test" ;
3939 }
4040 }
You can’t perform that action at this time.
0 commit comments