{"action":"created","comment":{"url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/comments/48808402","id":48808402,"diff_hunk":"@@ -0,0 +1,69 @@\n+// copied from https://github.com/howdyai/botkit version 0.0.5, original authors: @RafaelCosman and @guillaumepotier\n+\n+var redis = require('redis');\n+\n+/**\n+ * botkit-storage-redis - Redis driver for Botkit\n+ *\n+ * @param  {Object} config (optional) For full list of valid redis options, see\n+ *  https://github.com/NodeRedis/node_redis#options-is-an-object-with-the-following-possible-properties\n+ * @property config.namespace {String} The namespace to use when storing entities. Defaults to 'botkit:store'\n+ * @return {Object} Storage interface for Botkit\n+ */\n+module.exports = function(config) {\n+    config = config || {};\n+    config.namespace = config.namespace || 'botkit:store';\n+\n+    var storage = {},\n+        client = redis.createClient(config), // could pass specific redis config here\n+        methods = ['teams', 'users', 'channels'];\n+\n+    // Implements required API methods\n+    for (var i = 0; i < methods.length; i++) {\n+        storage[methods[i]] = getStorageObj(client, config.namespace + ':' + methods[i]);\n+    }\n+\n+    return storage;\n+};\n+\n+/**\n+ * Function to generate a storage object for a given namespace\n+ *\n+ * @param {Object} client The redis client\n+ * @param {String} namespace The namespace to use for storing in Redis\n+ * @returns {{get: get, save: save, all: all, allById: allById}}\n+ */\n+function getStorageObj(client, namespace) {\n+    return {\n+        get: function(id, cb) {\n+            client.hget(namespace, id, function(err, res) {\n+                cb(err, res ? JSON.parse(res) : {});\n+            });\n+        },\n+        save: function(object, cb) {\n+            if (!object.id) {\n+                return cb(new Error('The given object must have an id property'), {});\n+            }\n+\n+            client.hset(namespace, object.id, JSON.stringify(object), cb);\n+        },\n+        all: function(cb, options) {\n+            client.hgetall(namespace, function(err, res) {\n+                if (err) {\n+                    return cb(err, {});","path":"src/index.js","position":53,"original_position":53,"commit_id":"5bd10627ecfebfd28e2bfc8b88c6ff2d7f3dfacd","original_commit_id":"5bd10627ecfebfd28e2bfc8b88c6ff2d7f3dfacd","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":"please make this `cb(err)`","created_at":"2016-01-05T02:54:08Z","updated_at":"2016-01-05T02:54:08Z","html_url":"https://github.com/howdyai/botkit-storage-redis/pull/3#discussion_r48808402","pull_request_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/comments/48808402"},"html":{"href":"https://github.com/howdyai/botkit-storage-redis/pull/3#discussion_r48808402"},"pull_request":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3","id":55048563,"html_url":"https://github.com/howdyai/botkit-storage-redis/pull/3","diff_url":"https://github.com/howdyai/botkit-storage-redis/pull/3.diff","patch_url":"https://github.com/howdyai/botkit-storage-redis/pull/3.patch","issue_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/3","number":3,"state":"open","locked":false,"title":"Conventions","user":{"login":"colestrode","id":6707718,"avatar_url":"https://avatars.githubusercontent.com/u/6707718?v=3","gravatar_id":"","url":"https://api.github.com/users/colestrode","html_url":"https://github.com/colestrode","followers_url":"https://api.github.com/users/colestrode/followers","following_url":"https://api.github.com/users/colestrode/following{/other_user}","gists_url":"https://api.github.com/users/colestrode/gists{/gist_id}","starred_url":"https://api.github.com/users/colestrode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colestrode/subscriptions","organizations_url":"https://api.github.com/users/colestrode/orgs","repos_url":"https://api.github.com/users/colestrode/repos","events_url":"https://api.github.com/users/colestrode/events{/privacy}","received_events_url":"https://api.github.com/users/colestrode/received_events","type":"User","site_admin":false},"body":"I did what was outlined in the ticket and removed some unnecessary code (the config.methods option and allById method). I also moved jscs to a pretest script to be in line with the main botkit project.\r\n\r\nCloses #2 ","created_at":"2016-01-05T02:35:04Z","updated_at":"2016-01-05T02:54:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"03dcc9f981b24b3efc5f405f9011865cc7180684","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3/commits","review_comments_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3/comments","review_comment_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/3/comments","statuses_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/statuses/5bd10627ecfebfd28e2bfc8b88c6ff2d7f3dfacd","head":{"label":"colestrode:conventions","ref":"conventions","sha":"5bd10627ecfebfd28e2bfc8b88c6ff2d7f3dfacd","user":{"login":"colestrode","id":6707718,"avatar_url":"https://avatars.githubusercontent.com/u/6707718?v=3","gravatar_id":"","url":"https://api.github.com/users/colestrode","html_url":"https://github.com/colestrode","followers_url":"https://api.github.com/users/colestrode/followers","following_url":"https://api.github.com/users/colestrode/following{/other_user}","gists_url":"https://api.github.com/users/colestrode/gists{/gist_id}","starred_url":"https://api.github.com/users/colestrode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colestrode/subscriptions","organizations_url":"https://api.github.com/users/colestrode/orgs","repos_url":"https://api.github.com/users/colestrode/repos","events_url":"https://api.github.com/users/colestrode/events{/privacy}","received_events_url":"https://api.github.com/users/colestrode/received_events","type":"User","site_admin":false},"repo":{"id":49001651,"name":"botkit-storage-redis","full_name":"colestrode/botkit-storage-redis","owner":{"login":"colestrode","id":6707718,"avatar_url":"https://avatars.githubusercontent.com/u/6707718?v=3","gravatar_id":"","url":"https://api.github.com/users/colestrode","html_url":"https://github.com/colestrode","followers_url":"https://api.github.com/users/colestrode/followers","following_url":"https://api.github.com/users/colestrode/following{/other_user}","gists_url":"https://api.github.com/users/colestrode/gists{/gist_id}","starred_url":"https://api.github.com/users/colestrode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colestrode/subscriptions","organizations_url":"https://api.github.com/users/colestrode/orgs","repos_url":"https://api.github.com/users/colestrode/repos","events_url":"https://api.github.com/users/colestrode/events{/privacy}","received_events_url":"https://api.github.com/users/colestrode/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/colestrode/botkit-storage-redis","description":"Redis storage module for Botkit","fork":true,"url":"https://api.github.com/repos/colestrode/botkit-storage-redis","forks_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/forks","keys_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/teams","hooks_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/hooks","issue_events_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/issues/events{/number}","events_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/events","assignees_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/assignees{/user}","branches_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/branches{/branch}","tags_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/tags","blobs_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/git/refs{/sha}","trees_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/statuses/{sha}","languages_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/languages","stargazers_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/stargazers","contributors_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/contributors","subscribers_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/subscribers","subscription_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/subscription","commits_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/commits{/sha}","git_commits_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/git/commits{/sha}","comments_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/comments{/number}","issue_comment_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/issues/comments{/number}","contents_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/contents/{+path}","compare_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/merges","archive_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/downloads","issues_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/issues{/number}","pulls_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/pulls{/number}","milestones_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/milestones{/number}","notifications_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/labels{/name}","releases_url":"https://api.github.com/repos/colestrode/botkit-storage-redis/releases{/id}","created_at":"2016-01-04T14:22:39Z","updated_at":"2016-01-04T13:33:30Z","pushed_at":"2016-01-05T02:48:21Z","git_url":"git://github.com/colestrode/botkit-storage-redis.git","ssh_url":"git@github.com:colestrode/botkit-storage-redis.git","clone_url":"https://github.com/colestrode/botkit-storage-redis.git","svn_url":"https://github.com/colestrode/botkit-storage-redis","homepage":null,"size":20,"stargazers_count":0,"watchers_count":0,"language":null,"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":"master"}},"base":{"label":"howdyai:master","ref":"master","sha":"5e56006edf3a6abf4e1c30cea91930613b826514","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":48998846,"name":"botkit-storage-redis","full_name":"howdyai/botkit-storage-redis","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-storage-redis","description":"Redis storage module for Botkit","fork":false,"url":"https://api.github.com/repos/howdyai/botkit-storage-redis","forks_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/forks","keys_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/teams","hooks_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/hooks","issue_events_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/events{/number}","events_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/events","assignees_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/assignees{/user}","branches_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/branches{/branch}","tags_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/tags","blobs_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/git/refs{/sha}","trees_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/statuses/{sha}","languages_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/languages","stargazers_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/stargazers","contributors_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/contributors","subscribers_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/subscribers","subscription_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/subscription","commits_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/commits{/sha}","git_commits_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/git/commits{/sha}","comments_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/comments{/number}","issue_comment_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/comments{/number}","contents_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/contents/{+path}","compare_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/merges","archive_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/downloads","issues_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues{/number}","pulls_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls{/number}","milestones_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/milestones{/number}","notifications_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/labels{/name}","releases_url":"https://api.github.com/repos/howdyai/botkit-storage-redis/releases{/id}","created_at":"2016-01-04T13:31:43Z","updated_at":"2016-01-04T20:40:52Z","pushed_at":"2016-01-05T02:48:22Z","git_url":"git://github.com/howdyai/botkit-storage-redis.git","ssh_url":"git@github.com:howdyai/botkit-storage-redis.git","clone_url":"https://github.com/howdyai/botkit-storage-redis.git","svn_url":"https://github.com/howdyai/botkit-storage-redis","homepage":null,"size":13,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3"},"html":{"href":"https://github.com/howdyai/botkit-storage-redis/pull/3"},"issue":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/3"},"comments":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/howdyai/botkit-storage-redis/statuses/5bd10627ecfebfd28e2bfc8b88c6ff2d7f3dfacd"}}}}