我有一个.netCore记录器控制台应用程序。我想向我的项目添加一个slackLogger类库,因此在驱动程序中使用slackLog函数来记录到slack。
我在网上找到了此代码:
using System;
using SlackBotMessages;
namespace SlackLogger
{
public static class SlackLogger
{
var WebHookUrl = "https://hooks.slack.com/services/Your/WebHook/Url";
var client = new SbmClient(WebHookUrl);
var message = new Message("New member registered.").SetUserWithEmoji("Website", Emoji.Loudspeaker);
message.AddAttachment(new Attachment()
.AddField("Name", "jane doe", true)
.AddField("Website", "codeshare.co.uk", true)
.AddField("Job Title", "Developer", true)
.AddField("Company", "comp", true)
.AddField("Bio","something about me)
.SetThumbUrl("https://codeshare.co.uk/media/1508/paul-seal-profile-2019.jpg?width=500&height=500&mode=crop&anchor=top")
.SetColor("#f96332")
);
client.Send(message);
}
}
我将SlackBotMessages包添加到了依赖项中。但是,程序没有识别出任何标识符。
我在这里看不到我做错了。
答案 0 :(得分:0)
我更正了语法错误,现在可以使用吗?
using System;
using SlackBotMessages;
namespace SlackLogger
{
public static class SlackLogger
{
static string WebHookUrl = "https://hooks.slack.com/services/Your/WebHook/Url";
static SbmClient client = new SbmClient(WebHookUrl);
static Message message = new Message("New member registered.").SetUserWithEmoji("Website", Emoji.Loudspeaker);
message.AddAttachment(new Attachment()
.AddField("Name", "jane doe", true)
.AddField("Website", "codeshare.co.uk", true)
.AddField("Job Title", "Developer", true)
.AddField("Company", "comp", true)
.AddField("Bio","something about me")
.SetThumbUrl("https://codeshare.co.uk/media/1508/paul-seal-profile-2019.jpg?width=500&height=500&mode=crop&anchor=top")
.SetColor("#f96332")
);
client.Send(message);
}
}