Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix gosling to return goslings! #1310

Merged
merged 1 commit into from

3 participants

@austenito
  • Added case insensitivity to the regex
  • Updated the api route used to calculate total posts
@austenito austenito Fix gosling to return goslings!
- Added case insensitivity to the regex
- Updated the api route used to calculate total posts
4949c56
@technicalpickles technicalpickles merged commit 517add1 into github:master
@technicalpickles

We are actually moving away from adding scripts to repository in favor of separate npm packages per scripts. We have already stopped accepting new scripts, and will stop accepting pull requests on this repository after hubot 3.0.

See #1113 for details. If you are interested in maintaining this longer term, check npm in case someone already made a package for it, and if not, check out https://hubot.github.com/docs/scripting/ for creating a package of your own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 7, 2014
  1. @austenito

    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
View
8 src/scripts/gosling.coffee
@@ -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.