forked from hubot-archive/hubot-pugme
/
pugme.coffee
30 lines (26 loc) · 899 Bytes
/
pugme.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Description:
# Pugme is the most important thing in life
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot pug me - Receive a pug
# hubot pug bomb N - get N pugs
module.exports = (robot) ->
robot.respond /pug me/i, (msg) ->
msg.http("http://pugme.herokuapp.com/random")
.get() (err, res, body) ->
msg.send "http://" + JSON.parse(body).pug.split(".").slice(1).join(".")
robot.respond /pug bomb( (\d+))?/i, (msg) ->
count = msg.match[2] || 5
msg.http("http://pugme.herokuapp.com/bomb?count=" + count)
.get() (err, res, body) ->
msg.send ("http://" + pug.split(".").slice(1).join(".")) for pug in JSON.parse(body).pugs
robot.respond /how many pugs are there/i, (msg) ->
msg.http("http://pugme.herokuapp.com/count")
.get() (err, res, body) ->
msg.send "There are #{JSON.parse(body).pug_count} pugs."