{"action":"created","comment":{"url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/comments/58971865","id":58971865,"diff_hunk":"@@ -0,0 +1,138 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using FluentValidation.Results;\n+using NLog;\n+using NzbDrone.Core.Notifications.Slack.Payloads;\n+using NzbDrone.Core.Organizer;\n+using NzbDrone.Core.Rest;\n+using NzbDrone.Core.Tv;\n+using NzbDrone.Core.Validation;\n+using RestSharp;\n+\n+namespace NzbDrone.Core.Notifications.Slack\n+{\n+    public interface ISlackService\n+    {\n+        void OnDownload(DownloadMessage message, SlackSettings settings);\n+        void OnRename(Series series, SlackSettings settings);\n+        void OnGrab(GrabMessage message, SlackSettings settings);\n+        ValidationFailure Test(SlackSettings settings);\n+    }\n+\n+    public class SlackService : ISlackService\n+    {\n+        private readonly Logger _logger;\n+\n+        public SlackService(Logger logger)\n+        {\n+            _logger = logger;\n+        }\n+\n+        public void OnDownload(DownloadMessage message, SlackSettings settings)\n+        {\n+            var payload = new SlackPayload()\n+            {\n+                IconEmoji = settings.Icon,\n+                Username = settings.BotName,\n+                Text = \"Downloaded\",\n+                Attachments = new List<Attachment>()\n+                {\n+                    new Attachment()\n+                    {\n+                        Fallback = message.Message,\n+                        Title = message.Series.Title,\n+                        TitleLink = $\"http://www.imdb.com/title/{message.Series.ImdbId}/\",\n+                        Text = message.Message,\n+                        Color = \"good\"\n+                    }\n+                }\n+            };\n+\n+            NotifySlack(payload, settings);\n+        }\n+\n+        public void OnRename(Series series, SlackSettings settings)\n+        {\n+            var payload = new SlackPayload()\n+            {\n+                IconEmoji = settings.Icon,\n+                Username = settings.BotName,\n+                Text = \"Renamed\",\n+                Attachments = new List<Attachment>()\n+                {\n+                    new Attachment()\n+                    {\n+                        Title = series.Title,\n+                        TitleLink = $\"http://www.imdb.com/title/{series.ImdbId}/\",\n+                    }\n+                }\n+            };\n+\n+            NotifySlack(payload, settings);\n+        }\n+\n+        public void OnGrab(GrabMessage message, SlackSettings settings)\n+        {\n+            var payload = new SlackPayload()\n+            {\n+                IconEmoji = settings.Icon,\n+                Username = settings.BotName,\n+                Text = \"Grabbed\",\n+                Attachments = new List<Attachment>()\n+                {\n+                    new Attachment()\n+                    {\n+                        Fallback = message.Message,\n+                        Title = message.Series.Title,\n+                        TitleLink = $\"http://www.imdb.com/title/{message.Series.ImdbId}/\",","path":"src/NzbDrone.Core/Notifications/Slack/SlackService.cs","position":44,"original_position":87,"commit_id":"909cb35fad7dcf3672601a80caefa4e2bf025a44","original_commit_id":"909cb35fad7dcf3672601a80caefa4e2bf025a44","user":{"login":"markus101","id":413544,"avatar_url":"https://avatars.githubusercontent.com/u/413544?v=3","gravatar_id":"","url":"https://api.github.com/users/markus101","html_url":"https://github.com/markus101","followers_url":"https://api.github.com/users/markus101/followers","following_url":"https://api.github.com/users/markus101/following{/other_user}","gists_url":"https://api.github.com/users/markus101/gists{/gist_id}","starred_url":"https://api.github.com/users/markus101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markus101/subscriptions","organizations_url":"https://api.github.com/users/markus101/orgs","repos_url":"https://api.github.com/users/markus101/repos","events_url":"https://api.github.com/users/markus101/events{/privacy}","received_events_url":"https://api.github.com/users/markus101/received_events","type":"User","site_admin":false},"body":"For the time being I think we should stick with string.Format, we're going to be \r\n\r\nIMDB seems like an odd choice since we may not always have it (over half of the series don't) and it may not align with the TVDB, ideally this would be a link to the series in Sonarr, but not something we support for other notifications.","created_at":"2016-04-08T01:58:37Z","updated_at":"2016-04-08T01:58:37Z","html_url":"https://github.com/Sonarr/Sonarr/pull/1195#discussion_r58971865","pull_request_url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195","_links":{"self":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/comments/58971865"},"html":{"href":"https://github.com/Sonarr/Sonarr/pull/1195#discussion_r58971865"},"pull_request":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195"}}},"pull_request":{"url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195","id":63772610,"html_url":"https://github.com/Sonarr/Sonarr/pull/1195","diff_url":"https://github.com/Sonarr/Sonarr/pull/1195.diff","patch_url":"https://github.com/Sonarr/Sonarr/pull/1195.patch","issue_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1195","number":1195,"state":"open","locked":false,"title":"Support for Slack notifications","user":{"login":"mhartvig","id":6865872,"avatar_url":"https://avatars.githubusercontent.com/u/6865872?v=3","gravatar_id":"","url":"https://api.github.com/users/mhartvig","html_url":"https://github.com/mhartvig","followers_url":"https://api.github.com/users/mhartvig/followers","following_url":"https://api.github.com/users/mhartvig/following{/other_user}","gists_url":"https://api.github.com/users/mhartvig/gists{/gist_id}","starred_url":"https://api.github.com/users/mhartvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhartvig/subscriptions","organizations_url":"https://api.github.com/users/mhartvig/orgs","repos_url":"https://api.github.com/users/mhartvig/repos","events_url":"https://api.github.com/users/mhartvig/events{/privacy}","received_events_url":"https://api.github.com/users/mhartvig/received_events","type":"User","site_admin":false},"body":"Implemented slack as a notification channel through webhooks\r\nSupports the variables found in\r\nhttps://github.com/Sonarr/Sonarr/wiki/Custom-Post-Processing-Scripts in\r\nthe form \"$EventType\"\r\n\r\nHas the properties\r\nWebHookUrl (URL): `https://hooks.slack.com/TXXXXX/BXXXXX/XXXXXXXXXX`\r\nBotName (String): `Sonarr`\r\nIcon (String): `:ghost:` (http://www.emoji-cheat-sheet.com/)\r\nOnGrabPayload (String): `$EventType: $Series_Title - S$Release_SeasonNumberE$Release_EpisodeNumbers $Release_Title`\r\nOnDownloadPayload (String): `$EventType: $Series_Title - S$EpisodeFile_SeasonNumber:E$EpisodeFile_EpisodeNumbers $EpisodeFile_SceneName ($EpisodeFile_Quality)`\r\nOnRenamePayload (String): `$EventType: $Series_Title`\r\n","created_at":"2016-03-22T18:46:38Z","updated_at":"2016-04-08T01:58:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49607b359d262c863dde4c81d7cc9aa12fc1128b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195/commits","review_comments_url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195/comments","review_comment_url":"https://api.github.com/repos/Sonarr/Sonarr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1195/comments","statuses_url":"https://api.github.com/repos/Sonarr/Sonarr/statuses/909cb35fad7dcf3672601a80caefa4e2bf025a44","head":{"label":"mhartvig:Slack_Notifications","ref":"Slack_Notifications","sha":"909cb35fad7dcf3672601a80caefa4e2bf025a44","user":{"login":"mhartvig","id":6865872,"avatar_url":"https://avatars.githubusercontent.com/u/6865872?v=3","gravatar_id":"","url":"https://api.github.com/users/mhartvig","html_url":"https://github.com/mhartvig","followers_url":"https://api.github.com/users/mhartvig/followers","following_url":"https://api.github.com/users/mhartvig/following{/other_user}","gists_url":"https://api.github.com/users/mhartvig/gists{/gist_id}","starred_url":"https://api.github.com/users/mhartvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhartvig/subscriptions","organizations_url":"https://api.github.com/users/mhartvig/orgs","repos_url":"https://api.github.com/users/mhartvig/repos","events_url":"https://api.github.com/users/mhartvig/events{/privacy}","received_events_url":"https://api.github.com/users/mhartvig/received_events","type":"User","site_admin":false},"repo":{"id":54426669,"name":"Sonarr","full_name":"mhartvig/Sonarr","owner":{"login":"mhartvig","id":6865872,"avatar_url":"https://avatars.githubusercontent.com/u/6865872?v=3","gravatar_id":"","url":"https://api.github.com/users/mhartvig","html_url":"https://github.com/mhartvig","followers_url":"https://api.github.com/users/mhartvig/followers","following_url":"https://api.github.com/users/mhartvig/following{/other_user}","gists_url":"https://api.github.com/users/mhartvig/gists{/gist_id}","starred_url":"https://api.github.com/users/mhartvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhartvig/subscriptions","organizations_url":"https://api.github.com/users/mhartvig/orgs","repos_url":"https://api.github.com/users/mhartvig/repos","events_url":"https://api.github.com/users/mhartvig/events{/privacy}","received_events_url":"https://api.github.com/users/mhartvig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mhartvig/Sonarr","description":"Smart PVR for newsgroup and bittorrent users.","fork":true,"url":"https://api.github.com/repos/mhartvig/Sonarr","forks_url":"https://api.github.com/repos/mhartvig/Sonarr/forks","keys_url":"https://api.github.com/repos/mhartvig/Sonarr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mhartvig/Sonarr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mhartvig/Sonarr/teams","hooks_url":"https://api.github.com/repos/mhartvig/Sonarr/hooks","issue_events_url":"https://api.github.com/repos/mhartvig/Sonarr/issues/events{/number}","events_url":"https://api.github.com/repos/mhartvig/Sonarr/events","assignees_url":"https://api.github.com/repos/mhartvig/Sonarr/assignees{/user}","branches_url":"https://api.github.com/repos/mhartvig/Sonarr/branches{/branch}","tags_url":"https://api.github.com/repos/mhartvig/Sonarr/tags","blobs_url":"https://api.github.com/repos/mhartvig/Sonarr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mhartvig/Sonarr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mhartvig/Sonarr/git/refs{/sha}","trees_url":"https://api.github.com/repos/mhartvig/Sonarr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mhartvig/Sonarr/statuses/{sha}","languages_url":"https://api.github.com/repos/mhartvig/Sonarr/languages","stargazers_url":"https://api.github.com/repos/mhartvig/Sonarr/stargazers","contributors_url":"https://api.github.com/repos/mhartvig/Sonarr/contributors","subscribers_url":"https://api.github.com/repos/mhartvig/Sonarr/subscribers","subscription_url":"https://api.github.com/repos/mhartvig/Sonarr/subscription","commits_url":"https://api.github.com/repos/mhartvig/Sonarr/commits{/sha}","git_commits_url":"https://api.github.com/repos/mhartvig/Sonarr/git/commits{/sha}","comments_url":"https://api.github.com/repos/mhartvig/Sonarr/comments{/number}","issue_comment_url":"https://api.github.com/repos/mhartvig/Sonarr/issues/comments{/number}","contents_url":"https://api.github.com/repos/mhartvig/Sonarr/contents/{+path}","compare_url":"https://api.github.com/repos/mhartvig/Sonarr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mhartvig/Sonarr/merges","archive_url":"https://api.github.com/repos/mhartvig/Sonarr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mhartvig/Sonarr/downloads","issues_url":"https://api.github.com/repos/mhartvig/Sonarr/issues{/number}","pulls_url":"https://api.github.com/repos/mhartvig/Sonarr/pulls{/number}","milestones_url":"https://api.github.com/repos/mhartvig/Sonarr/milestones{/number}","notifications_url":"https://api.github.com/repos/mhartvig/Sonarr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mhartvig/Sonarr/labels{/name}","releases_url":"https://api.github.com/repos/mhartvig/Sonarr/releases{/id}","deployments_url":"https://api.github.com/repos/mhartvig/Sonarr/deployments","created_at":"2016-03-21T22:13:36Z","updated_at":"2016-03-21T22:13:41Z","pushed_at":"2016-03-27T19:45:21Z","git_url":"git://github.com/mhartvig/Sonarr.git","ssh_url":"git@github.com:mhartvig/Sonarr.git","clone_url":"https://github.com/mhartvig/Sonarr.git","svn_url":"https://github.com/mhartvig/Sonarr","homepage":"https://sonarr.tv","size":214409,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"Sonarr:develop","ref":"develop","sha":"d37343bb7dcaa72976ab2d2804ffe8b1c82b906a","user":{"login":"Sonarr","id":1082903,"avatar_url":"https://avatars.githubusercontent.com/u/1082903?v=3","gravatar_id":"","url":"https://api.github.com/users/Sonarr","html_url":"https://github.com/Sonarr","followers_url":"https://api.github.com/users/Sonarr/followers","following_url":"https://api.github.com/users/Sonarr/following{/other_user}","gists_url":"https://api.github.com/users/Sonarr/gists{/gist_id}","starred_url":"https://api.github.com/users/Sonarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sonarr/subscriptions","organizations_url":"https://api.github.com/users/Sonarr/orgs","repos_url":"https://api.github.com/users/Sonarr/repos","events_url":"https://api.github.com/users/Sonarr/events{/privacy}","received_events_url":"https://api.github.com/users/Sonarr/received_events","type":"Organization","site_admin":false},"repo":{"id":2465723,"name":"Sonarr","full_name":"Sonarr/Sonarr","owner":{"login":"Sonarr","id":1082903,"avatar_url":"https://avatars.githubusercontent.com/u/1082903?v=3","gravatar_id":"","url":"https://api.github.com/users/Sonarr","html_url":"https://github.com/Sonarr","followers_url":"https://api.github.com/users/Sonarr/followers","following_url":"https://api.github.com/users/Sonarr/following{/other_user}","gists_url":"https://api.github.com/users/Sonarr/gists{/gist_id}","starred_url":"https://api.github.com/users/Sonarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sonarr/subscriptions","organizations_url":"https://api.github.com/users/Sonarr/orgs","repos_url":"https://api.github.com/users/Sonarr/repos","events_url":"https://api.github.com/users/Sonarr/events{/privacy}","received_events_url":"https://api.github.com/users/Sonarr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sonarr/Sonarr","description":"Smart PVR for newsgroup and bittorrent users.","fork":false,"url":"https://api.github.com/repos/Sonarr/Sonarr","forks_url":"https://api.github.com/repos/Sonarr/Sonarr/forks","keys_url":"https://api.github.com/repos/Sonarr/Sonarr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sonarr/Sonarr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sonarr/Sonarr/teams","hooks_url":"https://api.github.com/repos/Sonarr/Sonarr/hooks","issue_events_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/events{/number}","events_url":"https://api.github.com/repos/Sonarr/Sonarr/events","assignees_url":"https://api.github.com/repos/Sonarr/Sonarr/assignees{/user}","branches_url":"https://api.github.com/repos/Sonarr/Sonarr/branches{/branch}","tags_url":"https://api.github.com/repos/Sonarr/Sonarr/tags","blobs_url":"https://api.github.com/repos/Sonarr/Sonarr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sonarr/Sonarr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sonarr/Sonarr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sonarr/Sonarr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sonarr/Sonarr/statuses/{sha}","languages_url":"https://api.github.com/repos/Sonarr/Sonarr/languages","stargazers_url":"https://api.github.com/repos/Sonarr/Sonarr/stargazers","contributors_url":"https://api.github.com/repos/Sonarr/Sonarr/contributors","subscribers_url":"https://api.github.com/repos/Sonarr/Sonarr/subscribers","subscription_url":"https://api.github.com/repos/Sonarr/Sonarr/subscription","commits_url":"https://api.github.com/repos/Sonarr/Sonarr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sonarr/Sonarr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sonarr/Sonarr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sonarr/Sonarr/contents/{+path}","compare_url":"https://api.github.com/repos/Sonarr/Sonarr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sonarr/Sonarr/merges","archive_url":"https://api.github.com/repos/Sonarr/Sonarr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sonarr/Sonarr/downloads","issues_url":"https://api.github.com/repos/Sonarr/Sonarr/issues{/number}","pulls_url":"https://api.github.com/repos/Sonarr/Sonarr/pulls{/number}","milestones_url":"https://api.github.com/repos/Sonarr/Sonarr/milestones{/number}","notifications_url":"https://api.github.com/repos/Sonarr/Sonarr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sonarr/Sonarr/labels{/name}","releases_url":"https://api.github.com/repos/Sonarr/Sonarr/releases{/id}","deployments_url":"https://api.github.com/repos/Sonarr/Sonarr/deployments","created_at":"2011-09-27T05:57:16Z","updated_at":"2016-04-08T01:23:37Z","pushed_at":"2016-04-07T22:52:06Z","git_url":"git://github.com/Sonarr/Sonarr.git","ssh_url":"git@github.com:Sonarr/Sonarr.git","clone_url":"https://github.com/Sonarr/Sonarr.git","svn_url":"https://github.com/Sonarr/Sonarr","homepage":"https://sonarr.tv","size":225129,"stargazers_count":1370,"watchers_count":1370,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":325,"mirror_url":null,"open_issues_count":398,"forks":325,"open_issues":398,"watchers":1370,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195"},"html":{"href":"https://github.com/Sonarr/Sonarr/pull/1195"},"issue":{"href":"https://api.github.com/repos/Sonarr/Sonarr/issues/1195"},"comments":{"href":"https://api.github.com/repos/Sonarr/Sonarr/issues/1195/comments"},"review_comments":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195/comments"},"review_comment":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sonarr/Sonarr/pulls/1195/commits"},"statuses":{"href":"https://api.github.com/repos/Sonarr/Sonarr/statuses/909cb35fad7dcf3672601a80caefa4e2bf025a44"}}}}