Skip to content

Instantly share code, notes, and snippets.

@darrenferguson
Created February 1, 2015 18:56
Show Gist options
  • Save darrenferguson/1a94ed6b374a46e2df86 to your computer and use it in GitHub Desktop.
Save darrenferguson/1a94ed6b374a46e2df86 to your computer and use it in GitHub Desktop.
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 = "[email protected]".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