forked from soxtoby/SlackNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
35 lines (27 loc) · 1.12 KB
/
Program.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
using Microsoft.Extensions.Configuration;
using NoContainerExample;
using SlackNet;
using SlackNet.Events;
Console.WriteLine("Configuring...");
var settings = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddUserSecrets<Program>()
.Build()
.Get<AppSettings>();
var slackServices = new SlackServiceBuilder()
// Configure the tokens used to authenticate with Slack
.UseApiToken(settings.ApiToken) // This gets used by the API client
.UseAppLevelToken(settings.AppLevelToken) // This gets used by the socket mode client
// Register your Slack handlers here
// The context object provides access to SlackNet services as well as the request context
.RegisterEventHandler<MessageEvent>(ctx => new PingDemo(ctx.ServiceProvider.GetApiClient()));
Console.WriteLine("Connecting...");
var client = slackServices.GetSocketModeClient();
await client.Connect();
Console.WriteLine("Connected. Press any key to exit...");
await Task.Run(Console.ReadKey);
record AppSettings
{
public string ApiToken { get; init; } = string.Empty;
public string AppLevelToken { get; init; } = string.Empty;
}