{"action":"created","comment":{"url":"https://api.github.com/repos/bra1n/judgebot/pulls/comments/85522388","pull_request_review_id":6233736,"id":85522388,"diff_hunk":"@@ -1,16 +1,96 @@\n+var request = require(\"request\");\n+var console = require(\"console\");\n+\n+const CR_ADDRESS = process.env.CR_ADDRESS; // http://media.wizards.com/2016/docs/MagicCompRules_20160930.txt or newer\n+\n class CR{\n     constructor(){\n-        this.Location = \"http://blogs.magicjudges.org/rules/cr/\";\n+\t\tthis.location = \"http://blogs.magicjudges.org/rules/cr/\";\n+\t\trequest({url: CR_ADDRESS, encoding: \"utf16le\"}, (error, response, body) => {\n+\t\t\t if (!error && response.statusCode == 200) {\n+\t\t\t\t let {cr, glossary} = parseCR(body);\n+\t\t\t\t this.cr = cr;\n+\t\t\t\t this.glossary = glossary;\n+\t\t\t\t console.log(\"CR Ready\")\n+\t\t\t } else {\n+\t\t\t\t console.error(error);\n+\t\t\t }\n+\t\t});\n     }\n     find (parameter,callback){\n-        //todo\n+        callback(this.cr.get(parameter.trim().replace(/\\.$/, \"\").toLowerCase()));\n     }\n     getContent(parameter,callback) {\n         if (parameter) {\n-            this.find(parameter, callback());\n+            this.find(parameter, callback);\n         } else {\n-            callback(this.Location);\n+            callback(this.location);\n         }\n     }\n+\tgetGlossaryEntry(parameter, callback) {\n+\t\tcallback(this.glossary.get(parameter.trim().toLowerCase()));\n+\t}\n }\n+\n+\n+function parseCR(crText) {\n+\tcrText = crText.replace(/\\r/g, \"\");\n+\n+\tlet rulesText = crText.substring(crText.search(\"\\n\\n100. General\\n\") + 2, crText.length);","path":"aggregators/rules/cr.js","position":43,"original_position":43,"commit_id":"d6d7273e563a44256e0b0c1757e60ade74ae2a84","original_commit_id":"d6d7273e563a44256e0b0c1757e60ade74ae2a84","user":{"login":"bra1n","id":325521,"avatar_url":"https://avatars.githubusercontent.com/u/325521?v=3","gravatar_id":"","url":"https://api.github.com/users/bra1n","html_url":"https://github.com/bra1n","followers_url":"https://api.github.com/users/bra1n/followers","following_url":"https://api.github.com/users/bra1n/following{/other_user}","gists_url":"https://api.github.com/users/bra1n/gists{/gist_id}","starred_url":"https://api.github.com/users/bra1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bra1n/subscriptions","organizations_url":"https://api.github.com/users/bra1n/orgs","repos_url":"https://api.github.com/users/bra1n/repos","events_url":"https://api.github.com/users/bra1n/events{/privacy}","received_events_url":"https://api.github.com/users/bra1n/received_events","type":"User","site_admin":false},"body":"`const` instead of `let`","created_at":"2016-10-28T12:41:53Z","updated_at":"2016-10-28T12:41:53Z","html_url":"https://github.com/bra1n/judgebot/pull/3#discussion_r85522388","pull_request_url":"https://api.github.com/repos/bra1n/judgebot/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/comments/85522388"},"html":{"href":"https://github.com/bra1n/judgebot/pull/3#discussion_r85522388"},"pull_request":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/bra1n/judgebot/pulls/3","id":91297788,"html_url":"https://github.com/bra1n/judgebot/pull/3","diff_url":"https://github.com/bra1n/judgebot/pull/3.diff","patch_url":"https://github.com/bra1n/judgebot/pull/3.patch","issue_url":"https://api.github.com/repos/bra1n/judgebot/issues/3","number":3,"state":"open","locked":false,"title":"Add parameter handling for !cr add !define command","user":{"login":"hgarus","id":4396799,"avatar_url":"https://avatars.githubusercontent.com/u/4396799?v=3","gravatar_id":"","url":"https://api.github.com/users/hgarus","html_url":"https://github.com/hgarus","followers_url":"https://api.github.com/users/hgarus/followers","following_url":"https://api.github.com/users/hgarus/following{/other_user}","gists_url":"https://api.github.com/users/hgarus/gists{/gist_id}","starred_url":"https://api.github.com/users/hgarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgarus/subscriptions","organizations_url":"https://api.github.com/users/hgarus/orgs","repos_url":"https://api.github.com/users/hgarus/repos","events_url":"https://api.github.com/users/hgarus/events{/privacy}","received_events_url":"https://api.github.com/users/hgarus/received_events","type":"User","site_admin":false},"body":"!cr [RuleNumber] can now be used to query a specific CR entry.\r\n\r\n!define [word] can be used to look up that word in the CR glossary.\r\n\r\nThe CR entries and glossary are parsed from the official CR txt release.\r\n\r\nThe url to retrieve the official txt release of the CR has to be\r\nconfigured as process.env.CR_ADDRESS.\r\n\r\nSlight rework of server.js:\r\n\r\nInstantiate each aggregator object only once and not on every command. Use\r\nan object as a lookup table instead of the switch case.","created_at":"2016-10-27T23:15:41Z","updated_at":"2016-10-28T12:46:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02a1261478088797f03bf7907f1c1b2d7f6d3fc5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bra1n/judgebot/pulls/3/commits","review_comments_url":"https://api.github.com/repos/bra1n/judgebot/pulls/3/comments","review_comment_url":"https://api.github.com/repos/bra1n/judgebot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bra1n/judgebot/issues/3/comments","statuses_url":"https://api.github.com/repos/bra1n/judgebot/statuses/d6d7273e563a44256e0b0c1757e60ade74ae2a84","head":{"label":"hgarus:master","ref":"master","sha":"d6d7273e563a44256e0b0c1757e60ade74ae2a84","user":{"login":"hgarus","id":4396799,"avatar_url":"https://avatars.githubusercontent.com/u/4396799?v=3","gravatar_id":"","url":"https://api.github.com/users/hgarus","html_url":"https://github.com/hgarus","followers_url":"https://api.github.com/users/hgarus/followers","following_url":"https://api.github.com/users/hgarus/following{/other_user}","gists_url":"https://api.github.com/users/hgarus/gists{/gist_id}","starred_url":"https://api.github.com/users/hgarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgarus/subscriptions","organizations_url":"https://api.github.com/users/hgarus/orgs","repos_url":"https://api.github.com/users/hgarus/repos","events_url":"https://api.github.com/users/hgarus/events{/privacy}","received_events_url":"https://api.github.com/users/hgarus/received_events","type":"User","site_admin":false},"repo":{"id":72155471,"name":"judgebot","full_name":"hgarus/judgebot","owner":{"login":"hgarus","id":4396799,"avatar_url":"https://avatars.githubusercontent.com/u/4396799?v=3","gravatar_id":"","url":"https://api.github.com/users/hgarus","html_url":"https://github.com/hgarus","followers_url":"https://api.github.com/users/hgarus/followers","following_url":"https://api.github.com/users/hgarus/following{/other_user}","gists_url":"https://api.github.com/users/hgarus/gists{/gist_id}","starred_url":"https://api.github.com/users/hgarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgarus/subscriptions","organizations_url":"https://api.github.com/users/hgarus/orgs","repos_url":"https://api.github.com/users/hgarus/repos","events_url":"https://api.github.com/users/hgarus/events{/privacy}","received_events_url":"https://api.github.com/users/hgarus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hgarus/judgebot","description":"Discord Bot for Magic / Judge related content","fork":true,"url":"https://api.github.com/repos/hgarus/judgebot","forks_url":"https://api.github.com/repos/hgarus/judgebot/forks","keys_url":"https://api.github.com/repos/hgarus/judgebot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hgarus/judgebot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hgarus/judgebot/teams","hooks_url":"https://api.github.com/repos/hgarus/judgebot/hooks","issue_events_url":"https://api.github.com/repos/hgarus/judgebot/issues/events{/number}","events_url":"https://api.github.com/repos/hgarus/judgebot/events","assignees_url":"https://api.github.com/repos/hgarus/judgebot/assignees{/user}","branches_url":"https://api.github.com/repos/hgarus/judgebot/branches{/branch}","tags_url":"https://api.github.com/repos/hgarus/judgebot/tags","blobs_url":"https://api.github.com/repos/hgarus/judgebot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hgarus/judgebot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hgarus/judgebot/git/refs{/sha}","trees_url":"https://api.github.com/repos/hgarus/judgebot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hgarus/judgebot/statuses/{sha}","languages_url":"https://api.github.com/repos/hgarus/judgebot/languages","stargazers_url":"https://api.github.com/repos/hgarus/judgebot/stargazers","contributors_url":"https://api.github.com/repos/hgarus/judgebot/contributors","subscribers_url":"https://api.github.com/repos/hgarus/judgebot/subscribers","subscription_url":"https://api.github.com/repos/hgarus/judgebot/subscription","commits_url":"https://api.github.com/repos/hgarus/judgebot/commits{/sha}","git_commits_url":"https://api.github.com/repos/hgarus/judgebot/git/commits{/sha}","comments_url":"https://api.github.com/repos/hgarus/judgebot/comments{/number}","issue_comment_url":"https://api.github.com/repos/hgarus/judgebot/issues/comments{/number}","contents_url":"https://api.github.com/repos/hgarus/judgebot/contents/{+path}","compare_url":"https://api.github.com/repos/hgarus/judgebot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hgarus/judgebot/merges","archive_url":"https://api.github.com/repos/hgarus/judgebot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hgarus/judgebot/downloads","issues_url":"https://api.github.com/repos/hgarus/judgebot/issues{/number}","pulls_url":"https://api.github.com/repos/hgarus/judgebot/pulls{/number}","milestones_url":"https://api.github.com/repos/hgarus/judgebot/milestones{/number}","notifications_url":"https://api.github.com/repos/hgarus/judgebot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hgarus/judgebot/labels{/name}","releases_url":"https://api.github.com/repos/hgarus/judgebot/releases{/id}","deployments_url":"https://api.github.com/repos/hgarus/judgebot/deployments","created_at":"2016-10-27T23:10:00Z","updated_at":"2016-10-27T23:10:01Z","pushed_at":"2016-10-27T23:11:43Z","git_url":"git://github.com/hgarus/judgebot.git","ssh_url":"git@github.com:hgarus/judgebot.git","clone_url":"https://github.com/hgarus/judgebot.git","svn_url":"https://github.com/hgarus/judgebot","homepage":null,"size":12,"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":"develop"}},"base":{"label":"bra1n:master","ref":"master","sha":"537487e6936d1bb9f28a5294f9a9b7bd5ecae7c9","user":{"login":"bra1n","id":325521,"avatar_url":"https://avatars.githubusercontent.com/u/325521?v=3","gravatar_id":"","url":"https://api.github.com/users/bra1n","html_url":"https://github.com/bra1n","followers_url":"https://api.github.com/users/bra1n/followers","following_url":"https://api.github.com/users/bra1n/following{/other_user}","gists_url":"https://api.github.com/users/bra1n/gists{/gist_id}","starred_url":"https://api.github.com/users/bra1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bra1n/subscriptions","organizations_url":"https://api.github.com/users/bra1n/orgs","repos_url":"https://api.github.com/users/bra1n/repos","events_url":"https://api.github.com/users/bra1n/events{/privacy}","received_events_url":"https://api.github.com/users/bra1n/received_events","type":"User","site_admin":false},"repo":{"id":71932182,"name":"judgebot","full_name":"bra1n/judgebot","owner":{"login":"bra1n","id":325521,"avatar_url":"https://avatars.githubusercontent.com/u/325521?v=3","gravatar_id":"","url":"https://api.github.com/users/bra1n","html_url":"https://github.com/bra1n","followers_url":"https://api.github.com/users/bra1n/followers","following_url":"https://api.github.com/users/bra1n/following{/other_user}","gists_url":"https://api.github.com/users/bra1n/gists{/gist_id}","starred_url":"https://api.github.com/users/bra1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bra1n/subscriptions","organizations_url":"https://api.github.com/users/bra1n/orgs","repos_url":"https://api.github.com/users/bra1n/repos","events_url":"https://api.github.com/users/bra1n/events{/privacy}","received_events_url":"https://api.github.com/users/bra1n/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bra1n/judgebot","description":"Discord Bot for Magic / Judge related content","fork":false,"url":"https://api.github.com/repos/bra1n/judgebot","forks_url":"https://api.github.com/repos/bra1n/judgebot/forks","keys_url":"https://api.github.com/repos/bra1n/judgebot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bra1n/judgebot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bra1n/judgebot/teams","hooks_url":"https://api.github.com/repos/bra1n/judgebot/hooks","issue_events_url":"https://api.github.com/repos/bra1n/judgebot/issues/events{/number}","events_url":"https://api.github.com/repos/bra1n/judgebot/events","assignees_url":"https://api.github.com/repos/bra1n/judgebot/assignees{/user}","branches_url":"https://api.github.com/repos/bra1n/judgebot/branches{/branch}","tags_url":"https://api.github.com/repos/bra1n/judgebot/tags","blobs_url":"https://api.github.com/repos/bra1n/judgebot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bra1n/judgebot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bra1n/judgebot/git/refs{/sha}","trees_url":"https://api.github.com/repos/bra1n/judgebot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bra1n/judgebot/statuses/{sha}","languages_url":"https://api.github.com/repos/bra1n/judgebot/languages","stargazers_url":"https://api.github.com/repos/bra1n/judgebot/stargazers","contributors_url":"https://api.github.com/repos/bra1n/judgebot/contributors","subscribers_url":"https://api.github.com/repos/bra1n/judgebot/subscribers","subscription_url":"https://api.github.com/repos/bra1n/judgebot/subscription","commits_url":"https://api.github.com/repos/bra1n/judgebot/commits{/sha}","git_commits_url":"https://api.github.com/repos/bra1n/judgebot/git/commits{/sha}","comments_url":"https://api.github.com/repos/bra1n/judgebot/comments{/number}","issue_comment_url":"https://api.github.com/repos/bra1n/judgebot/issues/comments{/number}","contents_url":"https://api.github.com/repos/bra1n/judgebot/contents/{+path}","compare_url":"https://api.github.com/repos/bra1n/judgebot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bra1n/judgebot/merges","archive_url":"https://api.github.com/repos/bra1n/judgebot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bra1n/judgebot/downloads","issues_url":"https://api.github.com/repos/bra1n/judgebot/issues{/number}","pulls_url":"https://api.github.com/repos/bra1n/judgebot/pulls{/number}","milestones_url":"https://api.github.com/repos/bra1n/judgebot/milestones{/number}","notifications_url":"https://api.github.com/repos/bra1n/judgebot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bra1n/judgebot/labels{/name}","releases_url":"https://api.github.com/repos/bra1n/judgebot/releases{/id}","deployments_url":"https://api.github.com/repos/bra1n/judgebot/deployments","created_at":"2016-10-25T19:36:02Z","updated_at":"2016-10-27T11:23:22Z","pushed_at":"2016-10-27T23:15:42Z","git_url":"git://github.com/bra1n/judgebot.git","ssh_url":"git@github.com:bra1n/judgebot.git","clone_url":"https://github.com/bra1n/judgebot.git","svn_url":"https://github.com/bra1n/judgebot","homepage":null,"size":11,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/3"},"html":{"href":"https://github.com/bra1n/judgebot/pull/3"},"issue":{"href":"https://api.github.com/repos/bra1n/judgebot/issues/3"},"comments":{"href":"https://api.github.com/repos/bra1n/judgebot/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bra1n/judgebot/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/bra1n/judgebot/statuses/d6d7273e563a44256e0b0c1757e60ade74ae2a84"}}}}
{"actor":{"display_login":"bra1n"}}