{"action":"created","comment":{"url":"https://api.github.com/repos/howdyai/botkit/pulls/comments/57519699","id":57519699,"diff_hunk":"@@ -227,7 +227,35 @@ bot.startRTM(function(err,bot,payload) {\n   if (err) {\n     throw new Error('Could not connect to Slack');\n   }\n+\n+  // close the RTM for the sake of it in 5 seconds\n+  setTimeout(function() {\n+      bot.closeRTM();\n+  }, 5000);\n+});\n+```\n+\n+#### bot.destroy()\n+\n+Completely shutdown and cleanup the spawned worker. Use `bot.closeRTM()` only to disconnect\n+but not completely tear down the worker.\n+\n+\n+```javascript\n+var Botkit = require('Botkit');\n+var controller = Botkit.slackbot();\n+var bot = controller.spawn({\n+  token: my_slack_bot_token\n+})\n+\n+bot.startRTM(function(err, bot, payload) {\n+  if (err) {\n+    throw new Error('Could not connect to Slack');\n+  }\n });\n+\n+// some time later (e.g. 10s) when finished with the RTM connection and worker","path":"readme.md","position":31,"original_position":31,"commit_id":"9c0473ca9bbb9698207de336ab27758d889a8b69","original_commit_id":"9c0473ca9bbb9698207de336ab27758d889a8b69","user":{"login":"anonrig","id":1935246,"avatar_url":"https://avatars.githubusercontent.com/u/1935246?v=3","gravatar_id":"","url":"https://api.github.com/users/anonrig","html_url":"https://github.com/anonrig","followers_url":"https://api.github.com/users/anonrig/followers","following_url":"https://api.github.com/users/anonrig/following{/other_user}","gists_url":"https://api.github.com/users/anonrig/gists{/gist_id}","starred_url":"https://api.github.com/users/anonrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anonrig/subscriptions","organizations_url":"https://api.github.com/users/anonrig/orgs","repos_url":"https://api.github.com/users/anonrig/repos","events_url":"https://api.github.com/users/anonrig/events{/privacy}","received_events_url":"https://api.github.com/users/anonrig/received_events","type":"User","site_admin":false},"body":"Great example of an obvious comment.","created_at":"2016-03-26T21:17:40Z","updated_at":"2016-03-26T21:17:40Z","html_url":"https://github.com/howdyai/botkit/pull/157#discussion_r57519699","pull_request_url":"https://api.github.com/repos/howdyai/botkit/pulls/157","_links":{"self":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/comments/57519699"},"html":{"href":"https://github.com/howdyai/botkit/pull/157#discussion_r57519699"},"pull_request":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/157"}}},"pull_request":{"url":"https://api.github.com/repos/howdyai/botkit/pulls/157","id":63507963,"html_url":"https://github.com/howdyai/botkit/pull/157","diff_url":"https://github.com/howdyai/botkit/pull/157.diff","patch_url":"https://github.com/howdyai/botkit/pull/157.patch","issue_url":"https://api.github.com/repos/howdyai/botkit/issues/157","number":157,"state":"open","locked":false,"title":"Add bot.destroy() to prevent memory leaks","user":{"login":"mbrevoort","id":30455,"avatar_url":"https://avatars.githubusercontent.com/u/30455?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrevoort","html_url":"https://github.com/mbrevoort","followers_url":"https://api.github.com/users/mbrevoort/followers","following_url":"https://api.github.com/users/mbrevoort/following{/other_user}","gists_url":"https://api.github.com/users/mbrevoort/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrevoort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrevoort/subscriptions","organizations_url":"https://api.github.com/users/mbrevoort/orgs","repos_url":"https://api.github.com/users/mbrevoort/repos","events_url":"https://api.github.com/users/mbrevoort/events{/privacy}","received_events_url":"https://api.github.com/users/mbrevoort/received_events","type":"User","site_admin":false},"body":"Currently there is no way to properly cleanup a spawned worker. This PR adds `bot.destroy()` to cleanup a worker. `destroy()` was added instead of overloading `bot.closeRTM()` since `spawn` is distinct from `bot.startRTM()` and you may want to close and RTM connection and reconnect without tearing down the worker.\r\n\r\n![leak](https://cloud.githubusercontent.com/assets/30455/13907263/ef139ac8-eeaf-11e5-96a3-86ef92875edd.gif)\r\n\r\nUpdate: I also added logic to detect stale connections if no `PONG` messages have been received.\r\n","created_at":"2016-03-20T21:25:19Z","updated_at":"2016-03-26T21:17:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"690ec08cbaeb3dec5d3bb5aca4199bbc392d3633","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/howdyai/botkit/pulls/157/commits","review_comments_url":"https://api.github.com/repos/howdyai/botkit/pulls/157/comments","review_comment_url":"https://api.github.com/repos/howdyai/botkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/howdyai/botkit/issues/157/comments","statuses_url":"https://api.github.com/repos/howdyai/botkit/statuses/9c0473ca9bbb9698207de336ab27758d889a8b69","head":{"label":"mbrevoort:master","ref":"master","sha":"9c0473ca9bbb9698207de336ab27758d889a8b69","user":{"login":"mbrevoort","id":30455,"avatar_url":"https://avatars.githubusercontent.com/u/30455?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrevoort","html_url":"https://github.com/mbrevoort","followers_url":"https://api.github.com/users/mbrevoort/followers","following_url":"https://api.github.com/users/mbrevoort/following{/other_user}","gists_url":"https://api.github.com/users/mbrevoort/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrevoort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrevoort/subscriptions","organizations_url":"https://api.github.com/users/mbrevoort/orgs","repos_url":"https://api.github.com/users/mbrevoort/repos","events_url":"https://api.github.com/users/mbrevoort/events{/privacy}","received_events_url":"https://api.github.com/users/mbrevoort/received_events","type":"User","site_admin":false},"repo":{"id":54298823,"name":"botkit","full_name":"mbrevoort/botkit","owner":{"login":"mbrevoort","id":30455,"avatar_url":"https://avatars.githubusercontent.com/u/30455?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrevoort","html_url":"https://github.com/mbrevoort","followers_url":"https://api.github.com/users/mbrevoort/followers","following_url":"https://api.github.com/users/mbrevoort/following{/other_user}","gists_url":"https://api.github.com/users/mbrevoort/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrevoort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrevoort/subscriptions","organizations_url":"https://api.github.com/users/mbrevoort/orgs","repos_url":"https://api.github.com/users/mbrevoort/repos","events_url":"https://api.github.com/users/mbrevoort/events{/privacy}","received_events_url":"https://api.github.com/users/mbrevoort/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mbrevoort/botkit","description":"Botkit is a toolkit for making bot applications","fork":true,"url":"https://api.github.com/repos/mbrevoort/botkit","forks_url":"https://api.github.com/repos/mbrevoort/botkit/forks","keys_url":"https://api.github.com/repos/mbrevoort/botkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mbrevoort/botkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mbrevoort/botkit/teams","hooks_url":"https://api.github.com/repos/mbrevoort/botkit/hooks","issue_events_url":"https://api.github.com/repos/mbrevoort/botkit/issues/events{/number}","events_url":"https://api.github.com/repos/mbrevoort/botkit/events","assignees_url":"https://api.github.com/repos/mbrevoort/botkit/assignees{/user}","branches_url":"https://api.github.com/repos/mbrevoort/botkit/branches{/branch}","tags_url":"https://api.github.com/repos/mbrevoort/botkit/tags","blobs_url":"https://api.github.com/repos/mbrevoort/botkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mbrevoort/botkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mbrevoort/botkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/mbrevoort/botkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mbrevoort/botkit/statuses/{sha}","languages_url":"https://api.github.com/repos/mbrevoort/botkit/languages","stargazers_url":"https://api.github.com/repos/mbrevoort/botkit/stargazers","contributors_url":"https://api.github.com/repos/mbrevoort/botkit/contributors","subscribers_url":"https://api.github.com/repos/mbrevoort/botkit/subscribers","subscription_url":"https://api.github.com/repos/mbrevoort/botkit/subscription","commits_url":"https://api.github.com/repos/mbrevoort/botkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/mbrevoort/botkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/mbrevoort/botkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/mbrevoort/botkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/mbrevoort/botkit/contents/{+path}","compare_url":"https://api.github.com/repos/mbrevoort/botkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mbrevoort/botkit/merges","archive_url":"https://api.github.com/repos/mbrevoort/botkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mbrevoort/botkit/downloads","issues_url":"https://api.github.com/repos/mbrevoort/botkit/issues{/number}","pulls_url":"https://api.github.com/repos/mbrevoort/botkit/pulls{/number}","milestones_url":"https://api.github.com/repos/mbrevoort/botkit/milestones{/number}","notifications_url":"https://api.github.com/repos/mbrevoort/botkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mbrevoort/botkit/labels{/name}","releases_url":"https://api.github.com/repos/mbrevoort/botkit/releases{/id}","deployments_url":"https://api.github.com/repos/mbrevoort/botkit/deployments","created_at":"2016-03-20T03:33:46Z","updated_at":"2016-03-20T03:33:47Z","pushed_at":"2016-03-24T18:50:24Z","git_url":"git://github.com/mbrevoort/botkit.git","ssh_url":"git@github.com:mbrevoort/botkit.git","clone_url":"https://github.com/mbrevoort/botkit.git","svn_url":"https://github.com/mbrevoort/botkit","homepage":null,"size":277,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"howdyai:master","ref":"master","sha":"28a98798e32133c5a18695f16a0bf1f5f233e7ad","user":{"login":"howdyai","id":16260958,"avatar_url":"https://avatars.githubusercontent.com/u/16260958?v=3","gravatar_id":"","url":"https://api.github.com/users/howdyai","html_url":"https://github.com/howdyai","followers_url":"https://api.github.com/users/howdyai/followers","following_url":"https://api.github.com/users/howdyai/following{/other_user}","gists_url":"https://api.github.com/users/howdyai/gists{/gist_id}","starred_url":"https://api.github.com/users/howdyai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howdyai/subscriptions","organizations_url":"https://api.github.com/users/howdyai/orgs","repos_url":"https://api.github.com/users/howdyai/repos","events_url":"https://api.github.com/users/howdyai/events{/privacy}","received_events_url":"https://api.github.com/users/howdyai/received_events","type":"Organization","site_admin":false},"repo":{"id":47851629,"name":"botkit","full_name":"howdyai/botkit","owner":{"login":"howdyai","id":16260958,"avatar_url":"https://avatars.githubusercontent.com/u/16260958?v=3","gravatar_id":"","url":"https://api.github.com/users/howdyai","html_url":"https://github.com/howdyai","followers_url":"https://api.github.com/users/howdyai/followers","following_url":"https://api.github.com/users/howdyai/following{/other_user}","gists_url":"https://api.github.com/users/howdyai/gists{/gist_id}","starred_url":"https://api.github.com/users/howdyai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howdyai/subscriptions","organizations_url":"https://api.github.com/users/howdyai/orgs","repos_url":"https://api.github.com/users/howdyai/repos","events_url":"https://api.github.com/users/howdyai/events{/privacy}","received_events_url":"https://api.github.com/users/howdyai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/howdyai/botkit","description":"Botkit is a toolkit for making bot applications","fork":false,"url":"https://api.github.com/repos/howdyai/botkit","forks_url":"https://api.github.com/repos/howdyai/botkit/forks","keys_url":"https://api.github.com/repos/howdyai/botkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/howdyai/botkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/howdyai/botkit/teams","hooks_url":"https://api.github.com/repos/howdyai/botkit/hooks","issue_events_url":"https://api.github.com/repos/howdyai/botkit/issues/events{/number}","events_url":"https://api.github.com/repos/howdyai/botkit/events","assignees_url":"https://api.github.com/repos/howdyai/botkit/assignees{/user}","branches_url":"https://api.github.com/repos/howdyai/botkit/branches{/branch}","tags_url":"https://api.github.com/repos/howdyai/botkit/tags","blobs_url":"https://api.github.com/repos/howdyai/botkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/howdyai/botkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/howdyai/botkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/howdyai/botkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/howdyai/botkit/statuses/{sha}","languages_url":"https://api.github.com/repos/howdyai/botkit/languages","stargazers_url":"https://api.github.com/repos/howdyai/botkit/stargazers","contributors_url":"https://api.github.com/repos/howdyai/botkit/contributors","subscribers_url":"https://api.github.com/repos/howdyai/botkit/subscribers","subscription_url":"https://api.github.com/repos/howdyai/botkit/subscription","commits_url":"https://api.github.com/repos/howdyai/botkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/howdyai/botkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/howdyai/botkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/howdyai/botkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/howdyai/botkit/contents/{+path}","compare_url":"https://api.github.com/repos/howdyai/botkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/howdyai/botkit/merges","archive_url":"https://api.github.com/repos/howdyai/botkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/howdyai/botkit/downloads","issues_url":"https://api.github.com/repos/howdyai/botkit/issues{/number}","pulls_url":"https://api.github.com/repos/howdyai/botkit/pulls{/number}","milestones_url":"https://api.github.com/repos/howdyai/botkit/milestones{/number}","notifications_url":"https://api.github.com/repos/howdyai/botkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/howdyai/botkit/labels{/name}","releases_url":"https://api.github.com/repos/howdyai/botkit/releases{/id}","deployments_url":"https://api.github.com/repos/howdyai/botkit/deployments","created_at":"2015-12-11T21:21:12Z","updated_at":"2016-03-26T20:50:45Z","pushed_at":"2016-03-24T18:50:34Z","git_url":"git://github.com/howdyai/botkit.git","ssh_url":"git@github.com:howdyai/botkit.git","clone_url":"https://github.com/howdyai/botkit.git","svn_url":"https://github.com/howdyai/botkit","homepage":null,"size":482,"stargazers_count":2723,"watchers_count":2723,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":44,"forks":288,"open_issues":44,"watchers":2723,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/157"},"html":{"href":"https://github.com/howdyai/botkit/pull/157"},"issue":{"href":"https://api.github.com/repos/howdyai/botkit/issues/157"},"comments":{"href":"https://api.github.com/repos/howdyai/botkit/issues/157/comments"},"review_comments":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/157/comments"},"review_comment":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/howdyai/botkit/pulls/157/commits"},"statuses":{"href":"https://api.github.com/repos/howdyai/botkit/statuses/9c0473ca9bbb9698207de336ab27758d889a8b69"}}}}