Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using RestSharp;
void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
foreach (var entity in e.PublishedEntities)
{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var url = umbracoHelper.Url(entity.Id, UrlProviderMode.Relative);
var urls = string.Format("https://slacker.moriyama.co.uk{0} or http://slacker.moriyama.int{0}", url);
var t = "New publish : " + entity.Name + " " + urls;
var hash = "bot@moriyama.co.uk".HashEmailForGravatar();
var client = new RestClient("https://slack.com/api");
var request = new RestRequest("/chat.postMessage", Method.POST);
request.AddParameter("token", "<top-secret>");
request.AddParameter("channel", "#mychannel");
request.AddParameter("username", "Moriyama Bot");
request.AddParameter("text", t);
request.AddParameter("icon_url", string.Format("http://www.gravatar.com/avatar/{0}", hash));
var response = client.Execute(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment