{"action":"created","comment":{"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/comments/63490703","id":63490703,"diff_hunk":"@@ -0,0 +1,38 @@\n+\"\"\" \n+For sending messages to Slack\n+\"\"\"\n+# Python libs\n+import logging\n+\n+from django.conf import settings\n+\n+from slacker import Slacker\n+\n+\n+class Slack():\n+    \n+    def __init__(self, auth_token):\n+        self.slack_client = Slacker(auth_token)\n+        \n+    def send_message_to_channel(self, channel, message):\n+        \"\"\" Sends a message to a slack channel \"\"\"\n+        if channel[0] == '#':\n+            pass\n+        else:\n+            channel = '#' + channel\n+     \n+              \n+        try:\n+            # Posting the message\n+            self.slack_client.chat.post_message(channel, message)\n+            return True\n+        except Exception, e: ","path":"seshdash/utils/send_slack.py","position":29,"original_position":29,"commit_id":"da94af700464add48c137559b5e0559e0a41bff8","original_commit_id":"da94af700464add48c137559b5e0559e0a41bff8","user":{"login":"jlark","id":956722,"avatar_url":"https://avatars.githubusercontent.com/u/956722?v=3","gravatar_id":"","url":"https://api.github.com/users/jlark","html_url":"https://github.com/jlark","followers_url":"https://api.github.com/users/jlark/followers","following_url":"https://api.github.com/users/jlark/following{/other_user}","gists_url":"https://api.github.com/users/jlark/gists{/gist_id}","starred_url":"https://api.github.com/users/jlark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlark/subscriptions","organizations_url":"https://api.github.com/users/jlark/orgs","repos_url":"https://api.github.com/users/jlark/repos","events_url":"https://api.github.com/users/jlark/events{/privacy}","received_events_url":"https://api.github.com/users/jlark/received_events","type":"User","site_admin":false},"body":"Here you need to actually check which exception is being thrown.\r\nSo if there is a specific slack exception that says channel does not exist you should catch that and do the necessary steps to create the channel. `except Exception,e` will create a channel on all exceptions regardless of the exception.","created_at":"2016-05-17T09:27:44Z","updated_at":"2016-05-17T09:27:44Z","html_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178#discussion_r63490703","pull_request_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/comments/63490703"},"html":{"href":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178#discussion_r63490703"},"pull_request":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178","id":70323850,"html_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178","diff_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178.diff","patch_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178.patch","issue_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/178","number":178,"state":"open","locked":false,"title":"Slack alert integration","user":{"login":"upatricck","id":8204177,"avatar_url":"https://avatars.githubusercontent.com/u/8204177?v=3","gravatar_id":"","url":"https://api.github.com/users/upatricck","html_url":"https://github.com/upatricck","followers_url":"https://api.github.com/users/upatricck/followers","following_url":"https://api.github.com/users/upatricck/following{/other_user}","gists_url":"https://api.github.com/users/upatricck/gists{/gist_id}","starred_url":"https://api.github.com/users/upatricck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/upatricck/subscriptions","organizations_url":"https://api.github.com/users/upatricck/orgs","repos_url":"https://api.github.com/users/upatricck/repos","events_url":"https://api.github.com/users/upatricck/events{/privacy}","received_events_url":"https://api.github.com/users/upatricck/received_events","type":"User","site_admin":false},"body":"## Done\r\n* Added Sesh_Organisation and Slack_Channel models\r\n* Functionality to report alerts on a specified alert channel\r\n\r\nThe slack authentication token for a sesh_organisation must be provided when creating the organisation","created_at":"2016-05-17T09:19:04Z","updated_at":"2016-05-17T09:27:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e4d48668cb6bf422a7a506fe0d05d170669753b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178/commits","review_comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178/comments","review_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/178/comments","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/statuses/da94af700464add48c137559b5e0559e0a41bff8","head":{"label":"GreatLakesEnergy:slack-alert-integration","ref":"slack-alert-integration","sha":"da94af700464add48c137559b5e0559e0a41bff8","user":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"repo":{"id":45332365,"name":"sesh-dash-beta","full_name":"GreatLakesEnergy/sesh-dash-beta","owner":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta","description":"SESH Dashboard beta. Working dev code","fork":false,"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta","forks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/forks","keys_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/teams","hooks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/hooks","issue_events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/events{/number}","events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/events","assignees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/assignees{/user}","branches_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/branches{/branch}","tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/tags","blobs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/refs{/sha}","trees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/statuses/{sha}","languages_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/languages","stargazers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/stargazers","contributors_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/contributors","subscribers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/subscribers","subscription_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/subscription","commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/commits{/sha}","git_commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/commits{/sha}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/comments{/number}","issue_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/comments{/number}","contents_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/contents/{+path}","compare_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/merges","archive_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/downloads","issues_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues{/number}","pulls_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls{/number}","milestones_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/milestones{/number}","notifications_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/labels{/name}","releases_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/releases{/id}","deployments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/deployments","created_at":"2015-11-01T07:54:15Z","updated_at":"2016-05-10T10:21:31Z","pushed_at":"2016-05-17T09:22:15Z","git_url":"git://github.com/GreatLakesEnergy/sesh-dash-beta.git","ssh_url":"git@github.com:GreatLakesEnergy/sesh-dash-beta.git","clone_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta.git","svn_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta","homepage":null,"size":10406,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":19,"forks":4,"open_issues":19,"watchers":4,"default_branch":"master"}},"base":{"label":"GreatLakesEnergy:master","ref":"master","sha":"97a52f847ff3f690c5afc141d90cd78d43e59ed6","user":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"repo":{"id":45332365,"name":"sesh-dash-beta","full_name":"GreatLakesEnergy/sesh-dash-beta","owner":{"login":"GreatLakesEnergy","id":13625235,"avatar_url":"https://avatars.githubusercontent.com/u/13625235?v=3","gravatar_id":"","url":"https://api.github.com/users/GreatLakesEnergy","html_url":"https://github.com/GreatLakesEnergy","followers_url":"https://api.github.com/users/GreatLakesEnergy/followers","following_url":"https://api.github.com/users/GreatLakesEnergy/following{/other_user}","gists_url":"https://api.github.com/users/GreatLakesEnergy/gists{/gist_id}","starred_url":"https://api.github.com/users/GreatLakesEnergy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreatLakesEnergy/subscriptions","organizations_url":"https://api.github.com/users/GreatLakesEnergy/orgs","repos_url":"https://api.github.com/users/GreatLakesEnergy/repos","events_url":"https://api.github.com/users/GreatLakesEnergy/events{/privacy}","received_events_url":"https://api.github.com/users/GreatLakesEnergy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta","description":"SESH Dashboard beta. Working dev code","fork":false,"url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta","forks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/forks","keys_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/teams","hooks_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/hooks","issue_events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/events{/number}","events_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/events","assignees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/assignees{/user}","branches_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/branches{/branch}","tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/tags","blobs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/refs{/sha}","trees_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/statuses/{sha}","languages_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/languages","stargazers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/stargazers","contributors_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/contributors","subscribers_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/subscribers","subscription_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/subscription","commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/commits{/sha}","git_commits_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/git/commits{/sha}","comments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/comments{/number}","issue_comment_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/comments{/number}","contents_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/contents/{+path}","compare_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/merges","archive_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/downloads","issues_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues{/number}","pulls_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls{/number}","milestones_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/milestones{/number}","notifications_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/labels{/name}","releases_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/releases{/id}","deployments_url":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/deployments","created_at":"2015-11-01T07:54:15Z","updated_at":"2016-05-10T10:21:31Z","pushed_at":"2016-05-17T09:22:15Z","git_url":"git://github.com/GreatLakesEnergy/sesh-dash-beta.git","ssh_url":"git@github.com:GreatLakesEnergy/sesh-dash-beta.git","clone_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta.git","svn_url":"https://github.com/GreatLakesEnergy/sesh-dash-beta","homepage":null,"size":10406,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":19,"forks":4,"open_issues":19,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178"},"html":{"href":"https://github.com/GreatLakesEnergy/sesh-dash-beta/pull/178"},"issue":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/178"},"comments":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/GreatLakesEnergy/sesh-dash-beta/statuses/da94af700464add48c137559b5e0559e0a41bff8"}}}}