Skip to content

Instantly share code, notes, and snippets.

@philnash
Created November 11, 2011 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philnash/1358569 to your computer and use it in GitHub Desktop.
Save philnash/1358569 to your computer and use it in GitHub Desktop.
placekitten.coffee
# hubot kitten <width>x<height> - get a kitten image
module.exports = (robot) ->
robot.respond /kitten(\s\d+(x\d+)?)?$/i, (msg) ->
size = msg.match[1]
sizes = size.split('x') if size?
if sizes
if sizes.length > 1
width = sizes[0].trim()
height = sizes[1].trim()
else
height = width = sizes[0].trim()
else
height = width = Math.floor(Math.random() * (500 - 100 + 1) + 100)
msg.send "http://placekitten.com/#{width}/#{height}#.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment