Skip to content

Releases: soxtoby/SlackNet

v0.10.0

24 Oct 03:35
Compare
Choose a tag to compare
  • Added logging.
  • Added SlackRequestContext.Current to provide static access to the current request context. Current throws if not in a request context, so depending on where you use it, you'll want to check IsAvailable first.
  • Added RequestId to SlackRequestContext, which provides a unique ID for the current request.
  • Added RequestId to RawSocketMessage and SocketMessage.
  • Fixes and extra properties for the OpenIdApi.Token API.

Logging

The default logger doesn't do anything, so if you want logging, you'll need to implement the ILogger interface and provide it with one of the UseLogger configuration methods. If you're using SlackNet.AspNetCore, the default logger is overridden with an adaptor for the Microsoft.Extensions.Logging logger, which itself can be overridden as necessary.

Implementing ILogger should be fairly straightforward - see the MicrosoftLoggerAdaptor for an example. I've provided a range of ILogEvent extension methods to adapt log events to a variety of formats. All log events have a Category property, and should have a "Source" message property, which can be used for filtering and determining the appropriate verbosity.

Breaking Changes

  • SlackNet.AspNetCore now depends on the Microsoft.Extensions.Logging.Abstractions package.
  • SlackRtmClient requires an ILogger when constructed with specific services.
  • CoreSocketModeClient requires an ILogger when constructed with specific services.
  • SlackSocketModeClient requires an ILogger when constructed.

Thankyou to @objmj-itminds for the Open ID improvements ✨

v0.9.5

23 Sep 08:24
ce9024f
Compare
Choose a tag to compare
  • Sign-in with slack support via Open ID api methods

Thankyou to @objmj-itminds for this release 🎁

v0.9.4

18 Aug 02:44
Compare
Choose a tag to compare
  • Implementation of oauth.v2.access method and required response types
  • Adding Team property to MessageEvent

Thanks to @objmj-itminds for the OAuth API work 🔒

v0.9.3

31 Jul 01:10
Compare
Choose a tag to compare
  • Added ChannelId and UserId properties to the FileShared event.

Thank you to @objmj-itminds for the addition 🛠

v0.9.2

27 Jun 04:15
Compare
Choose a tag to compare
  • Added optional includeLocale parameter to Info and List in UsersApi, and to Start in RtmApi.
  • SlashCommandResponses returned by ISlashCommandHandlers are properly passed on to Slack.

Potentially breaking changes

While the includeLocale parameters are optional, they haven't been added as the last parameter, so on the off chance you were using all of the optional parameters in one of the modified methods, without specifying parameter names, then you'll need to add some parameter names.

Thankyou to @Selm for helping with this release 👍

v0.9.1

01 May 00:50
Compare
Choose a tag to compare
  • Fixed null-ref when using socket mode with ASP.NET integration

v0.9.0

20 Apr 00:39
Compare
Choose a tag to compare

Socket Mode

This release introduces support for Slack's new socket mode. Socket mode gives you access to all the available Slack functionality without needing to host a public endpoint, which makes it ideal for testing a new application, or hosting it inside a local network.

TL;DR

See the SlackNet.SocketModeExample project for example usage. See Using a DI container below for example integration code. With a DI container, handler registration is the same as in SlackNet.EventsExample.

Using the built-in SlackServiceBuilder

var slackServices = new SlackServiceBuilder();
slackServices
    .UseAppLevelToken("<app-level OAuth token required for socket mode>")
    .RegisterEventHandler(myEventHandler)
    .RegisterBlockActionHandler(myBlockActionHandler);
var client = slackService.GetSocketModeClient();
await client.Connect();

SlackServiceBuilder provides registration methods for all the different types of handlers, as well as the ability to replace specific services with custom implementations, should the need arise.

It also provides methods to retrieve any of the SlackNet services, most notably GetApiClient and GetSocketModeClient.

The socket mode client

Similar to the RTM client, once connected, the socket mode client will reconnect automatically, until the client is disposed, or socket mode is disabled.

Each message received is treated as a "request", equivalent to receiving a request through the ASP.NET integration. Responses are returned as acknowledgements through the websocket connection.

By default, the socket mode client will open 2 connections, 10 seconds apart, so messages can still be received while one of the connections is being reconnected. You can configure this behaviour by passing a SocketModeConnectionOptions object into the client's Connect method.

Using a DI container

The built-in SlackServiceBuilder requires services and handlers to be constructed manually, but with a DI container, they can be registered with just a type, leaving construction to the container. Other services registered in the container can be injected as you'd expect, and services and handlers are given appropriate lifestyles.

Since the configuration has been standardised, it's pretty much the same for any container, but here's what it looks like for the provided integrations…

Autofac

Using the SlackNet.Autofac package:

var containerBuilder = new ContainerBuilder();
containerBuilder.AddSlackNet(c => c
    .UseAppLevelToken("<app-level OAuth token>")
    .RegisterEventHandler<MyEventHandler>()
    .RegisterBlockActionHandler<MyBlockActionHandler>());
var container = containerBuilder.Build();
var client = container.Resolve<ISlackSocketModeClient>();
await client.Connect();

Microsoft.Extensions.DependencyInjection

Using the SlackNet.Extensions.DependencyInjection package:

var serviceCollection = new ServiceCollection();
serviceCollection.AddSlackNet(c => c
    .UseAppLevelToken("<app-level OAuth token>")
    .RegisterEventHandler<MyEventHandler>()
    .RegisterBlockActionHandler<MyBlockActionHandler>());
var serviceProvider = serviceCollection.BuildServiceProvider();
var client = serviceProvider.GetRequiredService<ISlackSocketModeClient>();
await client.Connect();

SimpleInjector

Using the SlackNet.SimpleInjector package:

var container = new Container {
    // AsyncScopedLifestyle is used for scoping handlers
    Options = { DefaultScopedLifestyle = new AsyncScopedLifestyle() }
};
container.AddSlackNet(c => c
    .UseAppLevelToken("<app-level OAuth token>")
    .RegisterEventHandler<MyEventHandler>()
    .RegisterBlockActionHandler<MyBlockActionHandler>());
var client = container.GetInstance<ISlackSocketModeClient>();
await client.Connect();

Breaking Changes

SlackNet

  • Added a dependency on the Microsoft.Bcl.AsyncInterfaces package.
  • Default.Http takes in a Func<HttpClient> instead of just a HttpClient, to allow a client to be provided per request.
  • Default.RegisterServices has been removed.

SlackNet.AspNetCore

  • Added a dependency on the Microsoft.AspNetCore.Http and SlackNet.Extensions.DependencyInjection packages.
  • Updated Microsoft.Extensions.DependencyInjection.Abstractions dependency to 2.2.0.
  • SlackServiceConfiguration has been replaced with ServiceCollectionSlackServiceConfiguration as the configuration object passed to the AddSlackNet configuration callback.
  • IEventsObservables has been removed. It's simple enough to re-implement if anyone needs it, but it doesn't fit the rest of the API.

v0.8.2

11 Apr 00:11
Compare
Choose a tag to compare
  • Fixed empty ViewState.Values deserialization, which occurs when a modal dialog is closed without entering any values.
  • Added Description property to block kit Options for use with radio buttons.

v0.8.1

22 Mar 09:09
Compare
Choose a tag to compare
  • Added Files and Blocks to SlackBot's messages.

Thanks to @eFloh for this release ✨

v0.8.0

06 Mar 23:21
Compare
Choose a tag to compare

A few changes relating to Slack deprecating some of their old API features...

  • The API token is always sent up as a header - fixes authorization for Slack apps created after 24th February.

Breaking Changes

  • Channels, Groups, IM, and MPIM APIs have been removed. SlackNet.Bot APIs using these types will continue to work for now, but will be removed fairly soon.
  • EventCallback.AuthedUsers has been removed.