A barebones way of sending messages as a Slack Bot in C-Sharp.
Grab a DLL, whether it is a precompiled one found in releases or one built manually.
You can add the module to your project in Visual Studio by right-clicking on the References in the solution explorer, clicking Add Reference, and adding a new reference to SlackIntegration.dll where you have it stored.
using SlackIntegration;
namespace Example
{
public class ExampleClass
{
// Create a new, empty SlackBot
readonly SlackBot TestBot = new SlackBot();
// Store the webhooks URL that your Slack Bot uses to interface with a workspace channel
readonly string ChannelURL = "https://hooks.slack.com/services/Your/Web-Hooks-URL";
public void Main()
{
// int Slackbot.Send(string url, string data) -> int statuscode
Bot.Send(ChannelURL, "Hello World!");
}
}
}First, clone the source then navigate into it.
clone https://github.com/ethanavatar/C-Sharp-Slack-Integration.git
cd C-Sharp-Slack-IntegrationThen build using:
dotnet buildThen dll will be stored in bin/Debug/<framework>/SlackIntegration.dll
The provided precompiled versions are built using .NET Standard 2.0 which should work in most cases nowadays. However, it may not work if your project is targeting a version of .NET Standard or .NET Core older than 2.0, or .NET Framework older than 4.6.1 (among others that havent been tested). In these cases you can build using a different target framework.
Open the SlackIntegration.csproj file and change the value of <TargetFramework> from netstandard2.0 to a different valid framework version. See here for a list of valid framework versions. Not all versions within the previously stated "rule of thumb" have been tested. Some may require modifications and/or external toolkits in order to build properly.
For example, to build using .NET Framework 4.7.1, SlackIntegration.csproj should look like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
</PropertyGroup>
</Project>I am still relatively new to C-Sharp so contributions are greatly appreciated, as I will likely learn a lot from any critisism there might be. Despite it being a small project, I will try to make it as easy and useful as possible in the name of experience, and every piece of input counts.