 # Commands:
 #   hubot weather         provide weather information for the default cities
 #   hubot weather <city>  provide weather information for a <city>
-#   hubot forecast <city>  provide weather forecast for a <city>
+#   hubot forecast        provide weather forecast for the default cities
+#   hubot forecast <city> provide weather forecast for a <city>
 #   hubot weather help    explain OpenWeatherMap commands
 #
 # Author:

        msg.send "It is currently #{json.main.temp} #{named_unit} in #{json.name}."

  robot.respond /forecast (.*)/i, (msg) ->
    forecastFor(msg, msg.match[1])

  forecastFor = (msg, input) ->
    robot.http(forecastURL + input + "&appid=" + apiKey + "&units=" + units)
      .get() (err, res, body) ->
        if err
          msg.send "Encountered an error :( #{err}"
          return
        json = JSON.parse body
        msg.send "today we will have #{json.list[0].main.temp} #{named_unit} with #{json.list[0].weather[0].description} and feels like #{json.list[0].main.feels_like} #{named_unit}.\n Tomorrow we will have #{json.list[1].main.temp} #{named_unit} with #{json.list[1].weather[0].description} and feels like #{json.list[1].main.feels_like} #{named_unit}.\n The day after we will have #{json.list[2].main.temp} #{named_unit} with #{json.list[2].weather[0].description} and feels like #{json.list[2].main.feels_like} #{named_unit}.
  named_unit = switch
    when units == "metric" then "°C"
    when units == "imperial" then "°F"

#   github.com/tan3

weatherURL = process.env.HUBOT_OPEN_WEATHER_MAP_URL or 'http://api.openweathermap.org/data/2.5/weather?q='
findWeatherCoordinatesURL = process.env.HUBOT_OPEN_WEATHER_MAP_FIND_COORDINATES or 'http://api.openweathermap.org/data/2.5/find?q='
forecastURL = process.env.HUBOT_OPEN_WEATHER_MAP_FORECAST_URL or 'http://api.openweathermap.org/data/2.5/onecall?'
coordinates = process.env.HUBOT_OPEN_WEATHER_MAP_DEFAULT_COORDINATES
cities     = process.env.HUBOT_OPEN_WEATHER_MAP_DEFAULT_CITIES
apiKey     = process.env.HUBOT_OPEN_WEATHER_MAP_APIKEY
units      = process.env.HUBOT_OPEN_WEATHER_MAP_UNITS or 'imperial'
