forked from soxtoby/SlackNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppHome.cs
38 lines (34 loc) · 1.39 KB
/
AppHome.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using SlackNet;
using SlackNet.Blocks;
using SlackNet.Events;
namespace SlackNetDemo;
/// <summary>
/// Displays a list of things you can do with this demo when you open the app's home screen.
/// </summary>
class AppHome : IEventHandler<AppHomeOpened>
{
private readonly ISlackApiClient _slack;
public AppHome(ISlackApiClient slack) => _slack = slack;
public async Task Handle(AppHomeOpened slackEvent)
{
if (slackEvent.Tab == AppHomeTab.Home)
{
Console.WriteLine($"{(await _slack.Users.Info(slackEvent.User)).Name} opened the app's home view");
await _slack.Views.Publish(slackEvent.User, new HomeViewDefinition
{
Blocks =
{
new SectionBlock
{
Text = new Markdown($@"Welcome to the SlackNet example. Here's what you can do:
• Say ""{PingDemo.Trigger}"" to get back a pong
• Say ""{CounterDemo.Trigger}"" to get the counter demo
• Say ""{ModalViewDemo.Trigger}"" to open then modal view demo
• Use the `{EchoDemo.SlashCommand}` slash command to see an echo
• Set up a {Link.Url("https://api.slack.com/workflows", "workflow")} to automate sending messages to people")
}
}
}, slackEvent.View?.Hash);
}
}
}