Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 66155ce

Browse files
Merge pull request #914 from mwarkentin/patch-1
Make darksky international-friendly
2 parents 5000b5c + 4f3ddb7 commit 66155ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/scripts/darksky.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Configuration
88
# HUBOT_DARK_SKY_API_KEY
99
# HUBOT_DARK_SKY_DEFAULT_LOCATION
10+
# HUBOT_DARK_SKY_UNITS (optional - us, si, ca, or uk)
1011
#
1112
# Commands:
1213
# hubot weather - Get the weather for HUBOT_DARK_SKY_DEFAULT_LOCATION
@@ -40,6 +41,8 @@ module.exports = (robot) ->
4041

4142
darkSkyMe = (msg, lat, lng, cb) ->
4243
url = "https://api.forecast.io/forecast/#{process.env.HUBOT_DARK_SKY_API_KEY}/#{lat},#{lng}/"
44+
if process.env.HUBOT_DARK_SKY_UNITS
45+
url += "?units=#{process.env.HUBOT_DARK_SKY_UNITS}"
4346
msg.http(url)
4447
.get() (err, res, body) ->
4548
result = JSON.parse(body)
@@ -48,7 +51,7 @@ darkSkyMe = (msg, lat, lng, cb) ->
4851
cb "#{result.error}"
4952
return
5053

51-
response = "Currently: #{result.currently.summary} (#{result.currently.temperature}F)"
54+
response = "Currently: #{result.currently.summary} (#{result.currently.temperature}°)"
5255
response += "\nNext hour: #{result.hourly.summary}"
5356
response += "\nToday: #{result.daily.summary}"
5457
cb response

0 commit comments

Comments
 (0)