{"action":"created","comment":{"url":"https://api.github.com/repos/iwi/linkatos/pulls/comments/87279544","pull_request_review_id":7895016,"id":87279544,"diff_hunk":"@@ -5,75 +5,106 @@\n \n # starterbot's ID as an environment variable\n BOT_ID = os.environ.get(\"BOT_ID\")\n-\n-# constants\n-AT_BOT = \"<@\" + BOT_ID + \">\"\n-EXAMPLE_COMMAND = \"do\"\n-WEB_LINK = \"http\"\n-website_pattern = \"https?://\\S+(\\s|$)\"\n-prog = re.compile(website_pattern)\n+SLACK_BOT_TOKEN = os.environ.get(\"SLACK_BOT_TOKEN\"))\n \n # instantiate Slack & Twilio clients\n-slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))\n+slack_client = SlackClient(SLACK_BOT_TOKEN)\n \n \n-def bot_message (channel, text) :\n-    return slack_client.api_call(\"chat.postMessage\", \n+def bot_says (channel, text) :\n+    return slack_client.api_call(\"chat.postMessage\",\n                                  channel = channel,\n                                  text = text,\n                                  as_user = True)\n \n-def handle_command(command, channel) :\n+\n+def store_link (link, channel) :\n     \"\"\"\n-        Receives commands directed at the bot and determines if they\n-        are valid commands. If so, then acts on the commands. If not,\n-        returns back what it needs for clarification.\n+        Receives a link.\n+        Stores it in the db.\n+        Sends a confirmation message.\n     \"\"\"\n-    response = \"Not sure what you mean. Use the *\" + EXAMPLE_COMMAND + \\\n-               \"* command with numbers, delimited by spaces.\"\n-    if command.startswith(EXAMPLE_COMMAND) :\n-        response = \"Sure...write some more code then I can do that!\"\n-    \n-    bot_message(channel, response)\n+\n+    error = db.store(link)\n+    message = \"Success! The link has been stored\"\n+\n+    if error :\n+        message = \"ERROR: the link could not be stored\"\n+\n+    bot_says(channel, message)\n+\n+    return None\n+\n+\n+def message_contains_link (message) :\n+    \"\"\"\n+    Returns a link if it matches the regex\n+    \"\"\"\n+    website_pattern = \"https?://\\S+(\\s|$)\"\n+    prog = re.compile(website_pattern)","path":"linkatos.py","position":60,"original_position":60,"commit_id":"90f78f4429927e6f0f68ba30d9694b6d597bcd28","original_commit_id":"90f78f4429927e6f0f68ba30d9694b6d597bcd28","user":{"login":"arnau","id":33837,"avatar_url":"https://avatars.githubusercontent.com/u/33837?v=3","gravatar_id":"","url":"https://api.github.com/users/arnau","html_url":"https://github.com/arnau","followers_url":"https://api.github.com/users/arnau/followers","following_url":"https://api.github.com/users/arnau/following{/other_user}","gists_url":"https://api.github.com/users/arnau/gists{/gist_id}","starred_url":"https://api.github.com/users/arnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnau/subscriptions","organizations_url":"https://api.github.com/users/arnau/orgs","repos_url":"https://api.github.com/users/arnau/repos","events_url":"https://api.github.com/users/arnau/events{/privacy}","received_events_url":"https://api.github.com/users/arnau/received_events","type":"User","site_admin":false},"body":"Probablement sigui millor tenir el `re.compile` a fora o a la funció main perquè tal com està es recompila cada vegada que s'executa la funció. No farà una gran diferència perquè és petit però no costa res posar-ho fora :)","created_at":"2016-11-09T21:21:49Z","updated_at":"2016-11-09T21:21:49Z","html_url":"https://github.com/iwi/linkatos/pull/1#discussion_r87279544","pull_request_url":"https://api.github.com/repos/iwi/linkatos/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/comments/87279544"},"html":{"href":"https://github.com/iwi/linkatos/pull/1#discussion_r87279544"},"pull_request":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/iwi/linkatos/pulls/1","id":93035953,"html_url":"https://github.com/iwi/linkatos/pull/1","diff_url":"https://github.com/iwi/linkatos/pull/1.diff","patch_url":"https://github.com/iwi/linkatos/pull/1.patch","issue_url":"https://api.github.com/repos/iwi/linkatos/issues/1","number":1,"state":"open","locked":false,"title":"Simplification","user":{"login":"iwi","id":799282,"avatar_url":"https://avatars.githubusercontent.com/u/799282?v=3","gravatar_id":"","url":"https://api.github.com/users/iwi","html_url":"https://github.com/iwi","followers_url":"https://api.github.com/users/iwi/followers","following_url":"https://api.github.com/users/iwi/following{/other_user}","gists_url":"https://api.github.com/users/iwi/gists{/gist_id}","starred_url":"https://api.github.com/users/iwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwi/subscriptions","organizations_url":"https://api.github.com/users/iwi/orgs","repos_url":"https://api.github.com/users/iwi/repos","events_url":"https://api.github.com/users/iwi/events{/privacy}","received_events_url":"https://api.github.com/users/iwi/received_events","type":"User","site_admin":false},"body":"No està acabat, falta la reacció al link trobat","created_at":"2016-11-09T20:47:25Z","updated_at":"2016-11-09T21:42:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99bf985de356fb3164d34d00244ddce3d7644e62","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/iwi/linkatos/pulls/1/commits","review_comments_url":"https://api.github.com/repos/iwi/linkatos/pulls/1/comments","review_comment_url":"https://api.github.com/repos/iwi/linkatos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iwi/linkatos/issues/1/comments","statuses_url":"https://api.github.com/repos/iwi/linkatos/statuses/90f78f4429927e6f0f68ba30d9694b6d597bcd28","head":{"label":"iwi:simplification","ref":"simplification","sha":"90f78f4429927e6f0f68ba30d9694b6d597bcd28","user":{"login":"iwi","id":799282,"avatar_url":"https://avatars.githubusercontent.com/u/799282?v=3","gravatar_id":"","url":"https://api.github.com/users/iwi","html_url":"https://github.com/iwi","followers_url":"https://api.github.com/users/iwi/followers","following_url":"https://api.github.com/users/iwi/following{/other_user}","gists_url":"https://api.github.com/users/iwi/gists{/gist_id}","starred_url":"https://api.github.com/users/iwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwi/subscriptions","organizations_url":"https://api.github.com/users/iwi/orgs","repos_url":"https://api.github.com/users/iwi/repos","events_url":"https://api.github.com/users/iwi/events{/privacy}","received_events_url":"https://api.github.com/users/iwi/received_events","type":"User","site_admin":false},"repo":{"id":72935928,"name":"linkatos","full_name":"iwi/linkatos","owner":{"login":"iwi","id":799282,"avatar_url":"https://avatars.githubusercontent.com/u/799282?v=3","gravatar_id":"","url":"https://api.github.com/users/iwi","html_url":"https://github.com/iwi","followers_url":"https://api.github.com/users/iwi/followers","following_url":"https://api.github.com/users/iwi/following{/other_user}","gists_url":"https://api.github.com/users/iwi/gists{/gist_id}","starred_url":"https://api.github.com/users/iwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwi/subscriptions","organizations_url":"https://api.github.com/users/iwi/orgs","repos_url":"https://api.github.com/users/iwi/repos","events_url":"https://api.github.com/users/iwi/events{/privacy}","received_events_url":"https://api.github.com/users/iwi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iwi/linkatos","description":"a Python Slack bot","fork":false,"url":"https://api.github.com/repos/iwi/linkatos","forks_url":"https://api.github.com/repos/iwi/linkatos/forks","keys_url":"https://api.github.com/repos/iwi/linkatos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iwi/linkatos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iwi/linkatos/teams","hooks_url":"https://api.github.com/repos/iwi/linkatos/hooks","issue_events_url":"https://api.github.com/repos/iwi/linkatos/issues/events{/number}","events_url":"https://api.github.com/repos/iwi/linkatos/events","assignees_url":"https://api.github.com/repos/iwi/linkatos/assignees{/user}","branches_url":"https://api.github.com/repos/iwi/linkatos/branches{/branch}","tags_url":"https://api.github.com/repos/iwi/linkatos/tags","blobs_url":"https://api.github.com/repos/iwi/linkatos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iwi/linkatos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iwi/linkatos/git/refs{/sha}","trees_url":"https://api.github.com/repos/iwi/linkatos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iwi/linkatos/statuses/{sha}","languages_url":"https://api.github.com/repos/iwi/linkatos/languages","stargazers_url":"https://api.github.com/repos/iwi/linkatos/stargazers","contributors_url":"https://api.github.com/repos/iwi/linkatos/contributors","subscribers_url":"https://api.github.com/repos/iwi/linkatos/subscribers","subscription_url":"https://api.github.com/repos/iwi/linkatos/subscription","commits_url":"https://api.github.com/repos/iwi/linkatos/commits{/sha}","git_commits_url":"https://api.github.com/repos/iwi/linkatos/git/commits{/sha}","comments_url":"https://api.github.com/repos/iwi/linkatos/comments{/number}","issue_comment_url":"https://api.github.com/repos/iwi/linkatos/issues/comments{/number}","contents_url":"https://api.github.com/repos/iwi/linkatos/contents/{+path}","compare_url":"https://api.github.com/repos/iwi/linkatos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iwi/linkatos/merges","archive_url":"https://api.github.com/repos/iwi/linkatos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iwi/linkatos/downloads","issues_url":"https://api.github.com/repos/iwi/linkatos/issues{/number}","pulls_url":"https://api.github.com/repos/iwi/linkatos/pulls{/number}","milestones_url":"https://api.github.com/repos/iwi/linkatos/milestones{/number}","notifications_url":"https://api.github.com/repos/iwi/linkatos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iwi/linkatos/labels{/name}","releases_url":"https://api.github.com/repos/iwi/linkatos/releases{/id}","deployments_url":"https://api.github.com/repos/iwi/linkatos/deployments","created_at":"2016-11-05T15:45:52Z","updated_at":"2016-11-05T15:47:12Z","pushed_at":"2016-11-09T20:47:25Z","git_url":"git://github.com/iwi/linkatos.git","ssh_url":"git@github.com:iwi/linkatos.git","clone_url":"https://github.com/iwi/linkatos.git","svn_url":"https://github.com/iwi/linkatos","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"iwi:master","ref":"master","sha":"22a414f497331e31a59d72273b9672aceaa78f95","user":{"login":"iwi","id":799282,"avatar_url":"https://avatars.githubusercontent.com/u/799282?v=3","gravatar_id":"","url":"https://api.github.com/users/iwi","html_url":"https://github.com/iwi","followers_url":"https://api.github.com/users/iwi/followers","following_url":"https://api.github.com/users/iwi/following{/other_user}","gists_url":"https://api.github.com/users/iwi/gists{/gist_id}","starred_url":"https://api.github.com/users/iwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwi/subscriptions","organizations_url":"https://api.github.com/users/iwi/orgs","repos_url":"https://api.github.com/users/iwi/repos","events_url":"https://api.github.com/users/iwi/events{/privacy}","received_events_url":"https://api.github.com/users/iwi/received_events","type":"User","site_admin":false},"repo":{"id":72935928,"name":"linkatos","full_name":"iwi/linkatos","owner":{"login":"iwi","id":799282,"avatar_url":"https://avatars.githubusercontent.com/u/799282?v=3","gravatar_id":"","url":"https://api.github.com/users/iwi","html_url":"https://github.com/iwi","followers_url":"https://api.github.com/users/iwi/followers","following_url":"https://api.github.com/users/iwi/following{/other_user}","gists_url":"https://api.github.com/users/iwi/gists{/gist_id}","starred_url":"https://api.github.com/users/iwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwi/subscriptions","organizations_url":"https://api.github.com/users/iwi/orgs","repos_url":"https://api.github.com/users/iwi/repos","events_url":"https://api.github.com/users/iwi/events{/privacy}","received_events_url":"https://api.github.com/users/iwi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iwi/linkatos","description":"a Python Slack bot","fork":false,"url":"https://api.github.com/repos/iwi/linkatos","forks_url":"https://api.github.com/repos/iwi/linkatos/forks","keys_url":"https://api.github.com/repos/iwi/linkatos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iwi/linkatos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iwi/linkatos/teams","hooks_url":"https://api.github.com/repos/iwi/linkatos/hooks","issue_events_url":"https://api.github.com/repos/iwi/linkatos/issues/events{/number}","events_url":"https://api.github.com/repos/iwi/linkatos/events","assignees_url":"https://api.github.com/repos/iwi/linkatos/assignees{/user}","branches_url":"https://api.github.com/repos/iwi/linkatos/branches{/branch}","tags_url":"https://api.github.com/repos/iwi/linkatos/tags","blobs_url":"https://api.github.com/repos/iwi/linkatos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iwi/linkatos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iwi/linkatos/git/refs{/sha}","trees_url":"https://api.github.com/repos/iwi/linkatos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iwi/linkatos/statuses/{sha}","languages_url":"https://api.github.com/repos/iwi/linkatos/languages","stargazers_url":"https://api.github.com/repos/iwi/linkatos/stargazers","contributors_url":"https://api.github.com/repos/iwi/linkatos/contributors","subscribers_url":"https://api.github.com/repos/iwi/linkatos/subscribers","subscription_url":"https://api.github.com/repos/iwi/linkatos/subscription","commits_url":"https://api.github.com/repos/iwi/linkatos/commits{/sha}","git_commits_url":"https://api.github.com/repos/iwi/linkatos/git/commits{/sha}","comments_url":"https://api.github.com/repos/iwi/linkatos/comments{/number}","issue_comment_url":"https://api.github.com/repos/iwi/linkatos/issues/comments{/number}","contents_url":"https://api.github.com/repos/iwi/linkatos/contents/{+path}","compare_url":"https://api.github.com/repos/iwi/linkatos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iwi/linkatos/merges","archive_url":"https://api.github.com/repos/iwi/linkatos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iwi/linkatos/downloads","issues_url":"https://api.github.com/repos/iwi/linkatos/issues{/number}","pulls_url":"https://api.github.com/repos/iwi/linkatos/pulls{/number}","milestones_url":"https://api.github.com/repos/iwi/linkatos/milestones{/number}","notifications_url":"https://api.github.com/repos/iwi/linkatos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iwi/linkatos/labels{/name}","releases_url":"https://api.github.com/repos/iwi/linkatos/releases{/id}","deployments_url":"https://api.github.com/repos/iwi/linkatos/deployments","created_at":"2016-11-05T15:45:52Z","updated_at":"2016-11-05T15:47:12Z","pushed_at":"2016-11-09T20:47:25Z","git_url":"git://github.com/iwi/linkatos.git","ssh_url":"git@github.com:iwi/linkatos.git","clone_url":"https://github.com/iwi/linkatos.git","svn_url":"https://github.com/iwi/linkatos","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/1"},"html":{"href":"https://github.com/iwi/linkatos/pull/1"},"issue":{"href":"https://api.github.com/repos/iwi/linkatos/issues/1"},"comments":{"href":"https://api.github.com/repos/iwi/linkatos/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iwi/linkatos/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/iwi/linkatos/statuses/90f78f4429927e6f0f68ba30d9694b6d597bcd28"}}}}
{"actor":{"display_login":"arnau"}}