Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (30 sloc) 0.918 kb
# Description:
# Kittens!
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot kitten me - A randomly selected kitten
# hubot kitten me <w>x<h> - A kitten of the given size
# hubot kitten bomb me <number> - Many many kittens!
#
# Author:
# dstrelau
module.exports = (robot) ->
robot.respond /kittens?(?: me)?$/i, (msg) ->
msg.send kittenMe()
robot.respond /kittens?(?: me)? (\d+)(?:[x ](\d+))?$/i, (msg) ->
msg.send kittenMe msg.match[1], (msg.match[2] || msg.match[1])
robot.respond /kitten bomb(?: me)?( \d+)?$/i, (msg) ->
kittens = msg.match[1] || 5
msg.send(kittenMe()) for i in [1..kittens]
kittenMe = (height, width)->
h = height || Math.floor(Math.random()*250) + 250
w = width || Math.floor(Math.random()*250) + 250
root = "http://placekitten.com"
root += "/g" if Math.random() > 0.5 # greyscale kittens!
return "#{root}/#{h}/#{w}#.png"
Jump to Line
Something went wrong with that request. Please try again.