Created
February 1, 2015 18:56
-
-
Save darrenferguson/1a94ed6b374a46e2df86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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