{"action":"created","comment":{"url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/comments/48856609","id":48856609,"diff_hunk":"@@ -1,136 +1,121 @@\n # Description:\n-#   Roll x number of y sided dice. \n+#   Roll x number of y sided dice.\n #\n # Dependencies:\n-#\tNone\n+#   None\n #\n # Configuration:\n-#\tNone\n+#   None\n #\n # Commands:\n #   hubot roll me <n>d<sides> - rolls n number of n sided dice\n-# \thubot dice me <n>d<sides> - rolls n number of n sided dice\n-# \thubot roll <n>d<sides> - rolls n number of n sided dicee\n-#\thubot dice <n>d<sides> - rolls n number of n sided dice\n+#   hubot dice me <n>d<sides> - rolls n number of n sided dice\n+#   hubot roll <n>d<sides> - rolls n number of n sided dicee\n+#   hubot dice <n>d<sides> - rolls n number of n sided dice\n #\n # Author:\n-#\tWill Hinchman\n-#\tYes, I know dices isn't a word. Also, Yes, I like to make Hal sassy.\n+#   Will Hinchman\n+#   Yes, I know dices isn't a word. Also, Yes, I like to make Hal sassy.\n \n randomCrits = [\n-\t\"CRITS!\",\n-\t\"REKT!\",\n-\t\"It's super effective!\",\n-\t\"(boom)(roasted)\",\n-\t\"Throwing Rocks Tonight!\",\n-\t\"YES!\",\n-\t\"😍\",\n-\t\"😎😎😎\",\n-\t\"(burningalive)\",\n-\t\"(notbad)\",\n-\t\"(fuckyeah)\",\n-\t\"natch\"\n+  \"CRITS!\",\n+  \"REKT!\",\n+  \"It's super effective!\",\n+  \":boom:\",\n+  \"Throwing Rocks Tonight!\",\n+  \"YES!\",\n+  \"😍\",\n+  \"😎😎😎\",\n+  \"natch\"\n ]\n \n randomFails = [\n-\t\"FAIL!\",\n-\t\"(facepalm)\",\n-\t\"Oh. I'm Sorry.\",\n-\t\"That's... terrible\",\n-\t\"😐\",\n-\t\"Hope that wasn't important\",\n-\t\"😭\",\n-\t\"¯\\\\_(ツ)_/¯\",\n-\t\"TPK! TPK! TPK!\",\n-\t\"(areyoukiddingme)\",\n-\t\"(ohgodwhy)\"\n+  \"FAIL!\",\n+  \":facepalm:\",\n+  \"Oh. I'm Sorry.\",\n+  \"That's... terrible\",\n+  \"😐\",\n+  \"Hope that wasn't important\",\n+  \"😭\",\n+  \"¯\\\\_(ツ)_/¯\",\n+  \"TPK! TPK! TPK!\"\n ]\n \n randomNum = (max,min=0) ->\n-\treturn (Math.floor(Math.random() * (max - min) + min)) + 1\n+  return (Math.floor(Math.random() * (max - min) + min)) + 1\n # min is set to 0 by default but a different value can be passed to function\n \n parseDice = (diceRoll) ->\n-\tdiceRoll = diceRoll.replace /[\\a-c\\e-z\\s\\-\\_\\W+]/gi, \"\"\n-\tdiceRoll = diceRoll.replace /(\\s)/g, \"\"\n-\tdiceRoll = diceRoll.toLowerCase()\n+  diceRoll = diceRoll.replace /[\\a-c\\e-z\\s\\-\\_\\W+]/gi, \"\"\n+  diceRoll = diceRoll.replace /(\\s)/g, \"\"\n+  diceRoll = diceRoll.toLowerCase()\n \n rollDice = (dices,sides) ->\n-\toutDice = []\n+  outDice = []\n \n-\tfor i in [1..dices] by 1\n-\t\tnumber = randomNum(sides)\n-\t\tif sides == 100\n-\t\t\tnumber = number - 1\n-\t\toutDice.push number\n+  for i in [1..dices] by 1\n+    number = randomNum(sides)\n+    if sides == 100\n+      number = number - 1\n+    outDice.push number\n \n-\tdices = outDice\n+  dices = outDice\n \n \n averageDiceRolls = (dices,sides) ->\n-\tsum = 0\n-\tfor num in dices\n-\t\tsum = sum + num\n+  sum = 0\n+  for num in dices\n+    sum = sum + num\n \n-\tavg = sum/dices.length\n-\t#can't be less than 1.\n-\tif avg < 1.0\n-\t\tavg = 1.0\n+  avg = sum/dices.length\n+  #can't be less than 1.\n+  if avg < 1.0\n+    avg = 1.0\n \n-\treturn avg\n+  return avg\n \n module.exports = (robot) ->\n-\trobot.respond /(?:roll|dice)(?: me)?(.*)/i, (msg) ->\n-\t\tdiceToRoll = msg.match[1]\n-\t\tdiceToRoll = parseDice(diceToRoll)\t\n-\t\tuserName = msg.message.user.name\n-\t\tdiceArray = diceToRoll.split(\"d\")\n+  robot.respond /(?:roll|dice)(?: me)?(.*)/i, (msg) ->\n+    diceToRoll = msg.match[1]\n+    diceToRoll = parseDice(diceToRoll)\n+    userName = msg.message.user.name\n+    diceArray = diceToRoll.split(\"d\")\n \n-\t\tif not diceToRoll.length or !diceArray[1]\n-\t\t\tmsg.send \"Uhh, dice without sides don't exist, #{userName}. \\\"roll me <n>d<sides>\\\"\"\n-\t\telse\n-\t\t\tif diceArray.length == 2\n-\t\t\t\tdiceCount = diceArray[0]\n-\t\t\t\tsides = diceArray[1]\n+    if not diceToRoll.length or !diceArray[1]\n+      msg.send \"Uhh, dice without sides don't exist, #{userName}. \\\"roll me <n>d<sides>\\\"\"\n+    else\n+      if diceArray.length == 2\n+        diceCount = diceArray[0]\n+        sides = diceArray[1]\n \n-\t\t\t\tif diceCount > 20\n-\t\t\t\t\tdiceCount = 20\n-\t\t\t\t\tmsg.send \"Whoa, #{userName}, chill! Only 20 dice at a time please.\"\n+        if diceCount > 20\n+          diceCount = 20\n+          msg.send \"Whoa, #{userName}, chill! Only 20 dice at a time please.\"\n \n-\t\t\t\tif sides > 10000\n-\t\t\t\t\tsides = 10000\n-\t\t\t\t\tmsg.send \"Dude, #{userName}, more than ten thousand sides? I'm not a supercomputer, you know.\"\n-\t\t\t\t\n-\t\t\t\tif diceCount < 1\n-\t\t\t\t\tdiceCount = 1\n+        if sides > 10000\n+          sides = 10000\n+          msg.send \"Dude, #{userName}, more than ten thousand sides? I'm not a supercomputer, you know.\"","path":"scripts/dice.coffee","position":167,"original_position":167,"commit_id":"9f138395a0ef6da5760702f6df119c3de2346131","original_commit_id":"9f138395a0ef6da5760702f6df119c3de2346131","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line exceeds maximum allowed length","created_at":"2016-01-05T15:34:44Z","updated_at":"2016-01-05T15:34:44Z","html_url":"https://github.com/detroit-labs/hubot-badger/pull/174#discussion_r48856609","pull_request_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174","_links":{"self":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/comments/48856609"},"html":{"href":"https://github.com/detroit-labs/hubot-badger/pull/174#discussion_r48856609"},"pull_request":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174"}}},"pull_request":{"url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174","id":55104342,"html_url":"https://github.com/detroit-labs/hubot-badger/pull/174","diff_url":"https://github.com/detroit-labs/hubot-badger/pull/174.diff","patch_url":"https://github.com/detroit-labs/hubot-badger/pull/174.patch","issue_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/174","number":174,"state":"open","locked":false,"title":"replace HipChat emoticons with Slack emoticons","user":{"login":"macklinu","id":2344137,"avatar_url":"https://avatars.githubusercontent.com/u/2344137?v=3","gravatar_id":"","url":"https://api.github.com/users/macklinu","html_url":"https://github.com/macklinu","followers_url":"https://api.github.com/users/macklinu/followers","following_url":"https://api.github.com/users/macklinu/following{/other_user}","gists_url":"https://api.github.com/users/macklinu/gists{/gist_id}","starred_url":"https://api.github.com/users/macklinu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macklinu/subscriptions","organizations_url":"https://api.github.com/users/macklinu/orgs","repos_url":"https://api.github.com/users/macklinu/repos","events_url":"https://api.github.com/users/macklinu/events{/privacy}","received_events_url":"https://api.github.com/users/macklinu/received_events","type":"User","site_admin":false},"body":"fixes #170","created_at":"2016-01-05T15:34:33Z","updated_at":"2016-01-05T15:34:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50f5e5eefe1d238094c1ddb3735b683ef7cc7452","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174/commits","review_comments_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174/comments","review_comment_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/comments{/number}","comments_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/174/comments","statuses_url":"https://api.github.com/repos/detroit-labs/hubot-badger/statuses/9f138395a0ef6da5760702f6df119c3de2346131","head":{"label":"detroit-labs:170-switch-to-slack-emoticons","ref":"170-switch-to-slack-emoticons","sha":"9f138395a0ef6da5760702f6df119c3de2346131","user":{"login":"detroit-labs","id":805819,"avatar_url":"https://avatars.githubusercontent.com/u/805819?v=3","gravatar_id":"","url":"https://api.github.com/users/detroit-labs","html_url":"https://github.com/detroit-labs","followers_url":"https://api.github.com/users/detroit-labs/followers","following_url":"https://api.github.com/users/detroit-labs/following{/other_user}","gists_url":"https://api.github.com/users/detroit-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/detroit-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detroit-labs/subscriptions","organizations_url":"https://api.github.com/users/detroit-labs/orgs","repos_url":"https://api.github.com/users/detroit-labs/repos","events_url":"https://api.github.com/users/detroit-labs/events{/privacy}","received_events_url":"https://api.github.com/users/detroit-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":8279604,"name":"hubot-badger","full_name":"detroit-labs/hubot-badger","owner":{"login":"detroit-labs","id":805819,"avatar_url":"https://avatars.githubusercontent.com/u/805819?v=3","gravatar_id":"","url":"https://api.github.com/users/detroit-labs","html_url":"https://github.com/detroit-labs","followers_url":"https://api.github.com/users/detroit-labs/followers","following_url":"https://api.github.com/users/detroit-labs/following{/other_user}","gists_url":"https://api.github.com/users/detroit-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/detroit-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detroit-labs/subscriptions","organizations_url":"https://api.github.com/users/detroit-labs/orgs","repos_url":"https://api.github.com/users/detroit-labs/repos","events_url":"https://api.github.com/users/detroit-labs/events{/privacy}","received_events_url":"https://api.github.com/users/detroit-labs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/detroit-labs/hubot-badger","description":"The Crazy Nastyass Hubot Badger","fork":false,"url":"https://api.github.com/repos/detroit-labs/hubot-badger","forks_url":"https://api.github.com/repos/detroit-labs/hubot-badger/forks","keys_url":"https://api.github.com/repos/detroit-labs/hubot-badger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/detroit-labs/hubot-badger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/detroit-labs/hubot-badger/teams","hooks_url":"https://api.github.com/repos/detroit-labs/hubot-badger/hooks","issue_events_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/events{/number}","events_url":"https://api.github.com/repos/detroit-labs/hubot-badger/events","assignees_url":"https://api.github.com/repos/detroit-labs/hubot-badger/assignees{/user}","branches_url":"https://api.github.com/repos/detroit-labs/hubot-badger/branches{/branch}","tags_url":"https://api.github.com/repos/detroit-labs/hubot-badger/tags","blobs_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/refs{/sha}","trees_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/detroit-labs/hubot-badger/statuses/{sha}","languages_url":"https://api.github.com/repos/detroit-labs/hubot-badger/languages","stargazers_url":"https://api.github.com/repos/detroit-labs/hubot-badger/stargazers","contributors_url":"https://api.github.com/repos/detroit-labs/hubot-badger/contributors","subscribers_url":"https://api.github.com/repos/detroit-labs/hubot-badger/subscribers","subscription_url":"https://api.github.com/repos/detroit-labs/hubot-badger/subscription","commits_url":"https://api.github.com/repos/detroit-labs/hubot-badger/commits{/sha}","git_commits_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/commits{/sha}","comments_url":"https://api.github.com/repos/detroit-labs/hubot-badger/comments{/number}","issue_comment_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/comments{/number}","contents_url":"https://api.github.com/repos/detroit-labs/hubot-badger/contents/{+path}","compare_url":"https://api.github.com/repos/detroit-labs/hubot-badger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/detroit-labs/hubot-badger/merges","archive_url":"https://api.github.com/repos/detroit-labs/hubot-badger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/detroit-labs/hubot-badger/downloads","issues_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues{/number}","pulls_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls{/number}","milestones_url":"https://api.github.com/repos/detroit-labs/hubot-badger/milestones{/number}","notifications_url":"https://api.github.com/repos/detroit-labs/hubot-badger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/detroit-labs/hubot-badger/labels{/name}","releases_url":"https://api.github.com/repos/detroit-labs/hubot-badger/releases{/id}","created_at":"2013-02-18T23:39:33Z","updated_at":"2015-11-20T19:12:28Z","pushed_at":"2016-01-05T15:34:33Z","git_url":"git://github.com/detroit-labs/hubot-badger.git","ssh_url":"git@github.com:detroit-labs/hubot-badger.git","clone_url":"https://github.com/detroit-labs/hubot-badger.git","svn_url":"https://github.com/detroit-labs/hubot-badger","homepage":null,"size":3013,"stargazers_count":6,"watchers_count":6,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":6,"forks":24,"open_issues":6,"watchers":6,"default_branch":"master"}},"base":{"label":"detroit-labs:master","ref":"master","sha":"d67941f4ea4f11ab7a3f56e116b35c4ef75e4846","user":{"login":"detroit-labs","id":805819,"avatar_url":"https://avatars.githubusercontent.com/u/805819?v=3","gravatar_id":"","url":"https://api.github.com/users/detroit-labs","html_url":"https://github.com/detroit-labs","followers_url":"https://api.github.com/users/detroit-labs/followers","following_url":"https://api.github.com/users/detroit-labs/following{/other_user}","gists_url":"https://api.github.com/users/detroit-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/detroit-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detroit-labs/subscriptions","organizations_url":"https://api.github.com/users/detroit-labs/orgs","repos_url":"https://api.github.com/users/detroit-labs/repos","events_url":"https://api.github.com/users/detroit-labs/events{/privacy}","received_events_url":"https://api.github.com/users/detroit-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":8279604,"name":"hubot-badger","full_name":"detroit-labs/hubot-badger","owner":{"login":"detroit-labs","id":805819,"avatar_url":"https://avatars.githubusercontent.com/u/805819?v=3","gravatar_id":"","url":"https://api.github.com/users/detroit-labs","html_url":"https://github.com/detroit-labs","followers_url":"https://api.github.com/users/detroit-labs/followers","following_url":"https://api.github.com/users/detroit-labs/following{/other_user}","gists_url":"https://api.github.com/users/detroit-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/detroit-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detroit-labs/subscriptions","organizations_url":"https://api.github.com/users/detroit-labs/orgs","repos_url":"https://api.github.com/users/detroit-labs/repos","events_url":"https://api.github.com/users/detroit-labs/events{/privacy}","received_events_url":"https://api.github.com/users/detroit-labs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/detroit-labs/hubot-badger","description":"The Crazy Nastyass Hubot Badger","fork":false,"url":"https://api.github.com/repos/detroit-labs/hubot-badger","forks_url":"https://api.github.com/repos/detroit-labs/hubot-badger/forks","keys_url":"https://api.github.com/repos/detroit-labs/hubot-badger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/detroit-labs/hubot-badger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/detroit-labs/hubot-badger/teams","hooks_url":"https://api.github.com/repos/detroit-labs/hubot-badger/hooks","issue_events_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/events{/number}","events_url":"https://api.github.com/repos/detroit-labs/hubot-badger/events","assignees_url":"https://api.github.com/repos/detroit-labs/hubot-badger/assignees{/user}","branches_url":"https://api.github.com/repos/detroit-labs/hubot-badger/branches{/branch}","tags_url":"https://api.github.com/repos/detroit-labs/hubot-badger/tags","blobs_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/refs{/sha}","trees_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/detroit-labs/hubot-badger/statuses/{sha}","languages_url":"https://api.github.com/repos/detroit-labs/hubot-badger/languages","stargazers_url":"https://api.github.com/repos/detroit-labs/hubot-badger/stargazers","contributors_url":"https://api.github.com/repos/detroit-labs/hubot-badger/contributors","subscribers_url":"https://api.github.com/repos/detroit-labs/hubot-badger/subscribers","subscription_url":"https://api.github.com/repos/detroit-labs/hubot-badger/subscription","commits_url":"https://api.github.com/repos/detroit-labs/hubot-badger/commits{/sha}","git_commits_url":"https://api.github.com/repos/detroit-labs/hubot-badger/git/commits{/sha}","comments_url":"https://api.github.com/repos/detroit-labs/hubot-badger/comments{/number}","issue_comment_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/comments{/number}","contents_url":"https://api.github.com/repos/detroit-labs/hubot-badger/contents/{+path}","compare_url":"https://api.github.com/repos/detroit-labs/hubot-badger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/detroit-labs/hubot-badger/merges","archive_url":"https://api.github.com/repos/detroit-labs/hubot-badger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/detroit-labs/hubot-badger/downloads","issues_url":"https://api.github.com/repos/detroit-labs/hubot-badger/issues{/number}","pulls_url":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls{/number}","milestones_url":"https://api.github.com/repos/detroit-labs/hubot-badger/milestones{/number}","notifications_url":"https://api.github.com/repos/detroit-labs/hubot-badger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/detroit-labs/hubot-badger/labels{/name}","releases_url":"https://api.github.com/repos/detroit-labs/hubot-badger/releases{/id}","created_at":"2013-02-18T23:39:33Z","updated_at":"2015-11-20T19:12:28Z","pushed_at":"2016-01-05T15:34:33Z","git_url":"git://github.com/detroit-labs/hubot-badger.git","ssh_url":"git@github.com:detroit-labs/hubot-badger.git","clone_url":"https://github.com/detroit-labs/hubot-badger.git","svn_url":"https://github.com/detroit-labs/hubot-badger","homepage":null,"size":3013,"stargazers_count":6,"watchers_count":6,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":6,"forks":24,"open_issues":6,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174"},"html":{"href":"https://github.com/detroit-labs/hubot-badger/pull/174"},"issue":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/174"},"comments":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/issues/174/comments"},"review_comments":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174/comments"},"review_comment":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/pulls/174/commits"},"statuses":{"href":"https://api.github.com/repos/detroit-labs/hubot-badger/statuses/9f138395a0ef6da5760702f6df119c3de2346131"}}}}