forked from soxtoby/SlackNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
32 lines (26 loc) · 1.18 KB
/
Startup.cs
File metadata and controls
32 lines (26 loc) · 1.18 KB
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
using System;
using AzureFunctionExample;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using SlackNet.AspNetCore;
using SlackNet.Events;
[assembly: FunctionsStartup(typeof(Startup))]
namespace AzureFunctionExample;
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var apiToken = Environment.GetEnvironmentVariable("SlackApiToken", EnvironmentVariableTarget.Process);
var signingSecret = Environment.GetEnvironmentVariable("SlackSigningSecret", EnvironmentVariableTarget.Process);
builder.Services.AddSlackNet(c => c
// Configure the token used to authenticate with Slack
.UseApiToken(apiToken)
// Register your Slack handlers here
.RegisterEventHandler<MessageEvent, PingDemo>()
);
// This is roughly equivalent to the .UseSlackNet() call in ASP.NET Core
builder.Services.AddSingleton(new SlackEndpointConfiguration()
// The signing secret ensures that SlackNet only handles requests from Slack
.UseSigningSecret(signingSecret));
}
}