Slack.Integration 1.2.0

dotnet add package Slack.Integration --version 1.2.0                
NuGet\Install-Package Slack.Integration -Version 1.2.0                
此命令旨在在Visual Studio的包管理器控制台中使用,因为它使用NuGet模块的Install-Package版本。
<PackageReference Include="Slack.Integration" Version="1.2.0" />                
对于支持PackageReference的项目,请将此XML节点复制到项目文件中以引用该包。
paket add Slack.Integration --version 1.2.0                
#r "nuget: Slack.Integration, 1.2.0"                
#r指令可用于F# Interactive和Polyglot Notebooks。将此复制到交互工具或脚本的源代码中,以引用包。
// Install Slack.Integration as a Cake Addin
#addin nuget:?package=Slack.Integration&version=1.2.0

// Install Slack.Integration as a Cake Tool
#tool nuget:?package=Slack.Integration&version=1.2.0                

Slack.Integration

此库提供Slack API。您可以将服务与Slack集成。目前仅支持Incoming Webhook。

  • Incoming Webhook
  • Slash命令
  • 方便传递已知颜色和emoji

Releases GitHub license

支持的平台

  • .NET Framework 4.6.1+
  • .NET Standard 2.0+
  • .NET 5.0+

Incoming Webhook

使用起来非常简单。

var url = "<Your Incoming Webhook URL here.>";
var payload = new Payload { Text = "Hello, Slack!!" };
var client = new WebhookClient();
await client.SendAsync(url, payload);

以下是有效载荷示例。

var payload = new Payload
{
    UserName = "Incoming Webhook",
    Text = "Hello, @xin9le !!\n\nThis posts is test for _Incoming WebHook_ .\nDocument is <https://api.slack.com/incoming-webhooks|here>.",
    Markdown = true,
    Channel = "#random",  // override channel
    LinkNames = true,
    IconEmoji = KnownEmoji.PlusOne,
    Attachments = new []
    {
        new Attachment
        {
            Fallback = "脱・読みづらいコード!今日から一段上のプログラマーになる方法 5 選",
            Color = Color.AliceBlue.ToHex(),
            PreText = "This text is optional that is displayed at the top of _attachment block_ .",
            AuthorName = "xin9le",
            AuthorLink = "http://xin9le.net",
            AuthorIcon = "https://pbs.twimg.com/profile_images/1047114972118114305/vw07RO7H_normal.jpg",
            Title = "脱・読みづらいコード!今日から一段上のプログラマーになる方法 5 選",
            TitleLink = "http://blog.xin9le.net/entry/2016/02/26/043557",
            Text = "「ソースコードを綺麗に書く」というのは、プログラマーであれば誰しもが心掛けたいと思っている *極めて重要な事柄* です。そもそも「綺麗なコードってなんぞ?」という感じですが、いくつかあると思います。",
            ImageUrl = "http://cdn-ak.f.st-hatena.com/images/fotolife/x/xin9le/20160226/20160226040749.png",
            ThumbUrl = "https://pbs.twimg.com/profile_images/1047114972118114305/vw07RO7H_normal.jpg",
            Footer = "xin9le",
            FooterIcon = "https://pbs.twimg.com/profile_images/1047114972118114305/vw07RO7H_normal.jpg",
            Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds(),
            Fields = new []
            {
                new Field
                {
                    Title = "Unique User",
                    Value = "345",
                    Short = true,
                },
                new Field
                {
                    Title = "Page View",
                    Value = "12345",
                    Short = true,
                },
            },
            Actions = new []
            {
                new Slack.Integration.IncomingWebhook.Action
                {
                    Type = ActionType.Button,
                    Text = "GitHub",
                    Url = "https://github.com/xin9le",
                    Style = ActionStyle.Default,
                },
                new Slack.Integration.IncomingWebhook.Action
                {
                    Type = ActionType.Button,
                    Text = "Blog",
                    Url = "https://blog.xin9le.net",
                    Style = ActionStyle.Primary,
                },
                new Slack.Integration.IncomingWebhook.Action
                {
                    Type = ActionType.Button,
                    Text = "Twitter",
                    Url = "https://twitter.com/xin9le",
                    Style = ActionStyle.Danger,
                },
            },
        },
    },
};

2018-11-29 15 49 39

Slash命令

来自Slack的Slash命令请求可以映射如下。

using Microsoft.AspNetCore.Mvc;
using Slack.Integration.SlashCommand;

public class SlashCommandController : Controller
{
    [HttpPost]
    public IAsyncResult DoSomething([FromForm]Request request)  // request mapping
    {
        // do something
        return this.Ok();
    }
}

安装

从下载NuGet包开始。

dotnet add package Slack.Integration

许可证

此库以MIT许可提供。

作者

山之内隆明(又名@xin9le)是自2012年7月起获得Microsoft MVP for Developer Technologies (C#)的日本软件开发者。

产品 兼容的和额外的计算目标框架版本。
.NET net5.0 兼容。 net5.0-windows 被计算。 net6.0 兼容。 net6.0-android 被计算。 net6.0-ios 被计算。 net6.0-maccatalyst 被计算。 net6.0-macos 被计算。 net6.0-tvos 被计算。 net6.0-windows 被计算。 net7.0 被计算。 net7.0-android 被计算。 net7.0-ios 被计算。 net7.0-maccatalyst 被计算。 net7.0-macos 被计算。 net7.0-tvos 被计算。 net7.0-windows 被计算。 net8.0 被计算。 net8.0-android 被计算。 net8.0-browser 被计算。 net8.0-ios 被计算。 net8.0-maccatalyst 被计算。 net8.0-macos 被计算。 net8.0-tvos 被计算。 net8.0-windows 被计算。
.NET Core netcoreapp2.0 被计算。 netcoreapp2.1 被计算。 netcoreapp2.2 被计算。 netcoreapp3.0 被计算。 netcoreapp3.1 被计算。
.NET Standard netstandard2.0 兼容。 netstandard2.1 兼容。
.NET Framework net461 兼容。 net462 已计算。 net463 已计算。 net47 已计算。 net471 已计算。 net472 已计算。 net48 已计算。 net481 已计算。
MonoAndroid monoandroid 已计算。
MonoMac monomac 已计算。
MonoTouch monotouch 已计算。
Tizen tizen40 已计算。 tizen60 已计算。
Xamarin.iOS xamarinios 已计算。
Xamarin.Mac xamarinmac 已计算。
Xamarin.TVOS xamarintvos 已计算。
Xamarin.WatchOS xamarinwatchos 已计算。
兼容目标框架
包含的目标框架(在包中)
了解更多关于 目标框架.NET Standard

NuGet 包

此包未用于任何 NuGet 包。

GitHub 仓库

此包未用于任何流行的 GitHub 仓库。

版本 下载 最后更新时间
1.2.0 4,159 1/13/2022
1.1.0 1,539 12/16/2018
1.0.0 688 11/29/2018