/
shorts.coffee
36 lines (34 loc) · 926 Bytes
/
shorts.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
31
32
33
34
35
36
# Description:
# Shorts
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot can i wear shorts
# hubot mag ik een korte broek aan
# hubot shorts?
#
# Author:
# Marthyn (@Marthyn)
module.exports = (robot) ->
robot.respond /can i wear shorts/, (msg) ->
getTemperature(msg, robot)
robot.respond /mag ik een korte broek aan/, (msg) ->
getTemperature(msg, robot)
robot.respond /shorts\?/, (msg) ->
getTemperature(msg, robot)
getTemperature = (msg, robot) ->
url = "http://api.openweathermap.org/data/2.5/forecast/daily
?q=Rotterdam,nl&units=metric&cnt=1"
robot.http(url).get() (err, res, body) ->
data = JSON.parse body
if data.list[0].main.temp_max
temp = data.list[0].main.temp_max
if temp >= 30
msg.send "Yes, the temperature is #{temp}! Show them legs!"
else
msg.send "No, it's only #{temp}, please show some respect"