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

Commit aa438be

Browse files
author
Christoph Halang
committed
added metric system forecasts to wunderground script
1 parent 1de5575 commit aa438be

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/scripts/wunderground.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77
# Configuration:
88
# HUBOT_WUNDERGROUND_API_KEY Sign up at http://www.wunderground.com/weather/api/.
9+
# HUBOT_WUNDERGROUND_USE_METRIC (heroku config:unset HUBOT_WUNDERGROUND_USE_METRIC to disable)
910
#
1011
# Commands:
1112
# hubot weather me <location> - short-term forecast
@@ -87,8 +88,10 @@ get_data = (robot, msg, location, service, query, cb, lifetime, stack=0) ->
8788

8889
send_forecast = (msg, location, data) ->
8990
report = data.forecast.txt_forecast.forecastday[0]
90-
msg.send "#{report.title} in #{location}: #{report.fcttext} (#{formatted_ttl data})"
91-
91+
if not process.env.HUBOT_WUNDERGROUND_USE_METRIC?
92+
msg.send "#{report.title} in #{location}: #{report.fcttext} (#{formatted_ttl data})"
93+
else
94+
msg.send "#{report.title} in #{location}: #{report.fcttext_metric} (#{formatted_ttl data})"
9295
send_radar = (msg, location, data) ->
9396
msg.send "#{data.radar.image_url}#.png"
9497

@@ -121,4 +124,4 @@ ttl = (data) ->
121124

122125
alternative_place = (item) ->
123126
return '' if item.country != 'US' || item.state == "" || item.city == ""
124-
return "#{item.state}/#{item.city.replace(/\s/g, '_')}"
127+
return "#{item.state}/#{item.city.replace(/\s/g, '_')}"

0 commit comments

Comments
 (0)