Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix gosling to return goslings! #1310

Open
wants to merge 1 commit into from

2 participants

Austen Ito travisvalentine
Austen Ito
  • Added case insensitivity to the regex
  • Updated the api route used to calculate total posts
Austen Ito austenito Fix gosling to return goslings!
- Added case insensitivity to the regex
- Updated the api route used to calculate total posts
4949c56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 7, 2014
  1. Austen Ito

    Fix gosling to return goslings!

    austenito authored
    - Added case insensitivity to the regex
    - Updated the api route used to calculate total posts
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/scripts/gosling.coffee
8 src/scripts/gosling.coffee
View
@@ -22,16 +22,16 @@ getRandomGoslingImageUrl = (msg, rand) ->
msg.send(post.response.posts[0].photos[0].original_size.url)
getGoslingImage = (msg) ->
- msg.http("http://api.tumblr.com/v2/blog/programmerryangosling.tumblr.com/info?api_key=#{api_key}").get() (err, res, body) ->
- total_posts = JSON.parse(body).response.blog.posts
+ msg.http("http://api.tumblr.com/v2/blog/programmerryangosling.tumblr.com/posts?api_key=#{api_key}").get() (err, res, body) ->
+ total_posts = JSON.parse(body).response.posts.length
rand = Math.floor(Math.random() * total_posts)
getRandomGoslingImageUrl(msg, rand)
module.exports = (robot) ->
- robot.respond /gos(ling)? me/, (msg) ->
+ robot.respond /gos(ling)? me/i, (msg) ->
getGoslingImage(msg)
- robot.respond /gos(ling)? bomb (\d+)/, (msg) ->
+ robot.respond /gos(ling)? bomb (\d+)/i, (msg) ->
count = msg.match[2] || 5
for num in [count..1]
getGoslingImage(msg)
Something went wrong with that request. Please try again.