Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/narochno/narochno.slack
A simple Slack client.
https://github.com/narochno/narochno.slack
c-sharp netcore netstandard slack
Last synced: about 1 month ago
JSON representation
A simple Slack client.
- Host: GitHub
- URL: https://github.com/narochno/narochno.slack
- Owner: Narochno
- License: mit
- Created: 2016-12-19T20:47:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T08:56:00.000Z (about 2 years ago)
- Last Synced: 2024-04-30T01:42:58.523Z (9 months ago)
- Topics: c-sharp, netcore, netstandard, slack
- Language: C#
- Size: 56.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Narochno.Slack [![Build status](https://ci.appveyor.com/api/projects/status/ru0cu26ooe7bbigk/branch/master?svg=true)](https://ci.appveyor.com/project/Narochno/narochno-slack/branch/master) [![NuGet](https://img.shields.io/nuget/v/Narochno.Slack.svg)](https://www.nuget.org/packages/Narochno.Slack/)
A simple Slack client for posting messages with fields and attachments, narochno.
## Example Usage
```csharp
var config = new SlackConfig
{
WebHookUrl = "your webhook URL"
};var message = new IncomingWebHookRequest
{
Text = "test",
Channel = "#test",
UserName = "a user",
IconEmoji = ":ghost:",
Attachments = new List
{
new Attachment
{
Title = "tite",
Color = "#993",
Fallback = "fallback"
}
}
};# Optionally dispose
using (var slackClient = new SlackClient(config))
{
await slackClient.IncomingWebHook(message);
}
```ASP.NET Core DI setup
```csharp
var services = new ServiceCollection();
services.AddSlack(new SlackConfig{ ... });
var provider = services.BuildServiceProvider();
```Or completely manually to control building of HTTP client:
```csharp
var services = new ServiceCollection();services.AddSingleton(new SlackConfig{ ... })
services.AddHttpClient()
.AddPolicyHandler(GetRetryPolicy()); // defined in the consumer's codevar provider = services.BuildServiceProvider();
var slackClient = provider.GetRequiredService();
```