Skip to content
Snippets Groups Projects
Verified Commit 43b6f5af authored by Erick Hitter's avatar Erick Hitter
Browse files

Change layout to indicate location and PWS

parent 300f8643
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,8 @@ app.post('/post', function(req, res){ ...@@ -54,6 +54,8 @@ app.post('/post', function(req, res){
var weatherCondition = conditionData.current_observation.weather; var weatherCondition = conditionData.current_observation.weather;
var icon_url = conditionData.current_observation.icon_url; var icon_url = conditionData.current_observation.icon_url;
var location = conditionData.current_observation.display_location.full; var location = conditionData.current_observation.display_location.full;
var obsLocation = conditionData.current_observation.observation_location.full;
var stationID = conditionData.current_observation.station_id;
parsed_url = url.format({ parsed_url = url.format({
pathname: 'http://api.wunderground.com/api/' + apikey + '/forecast/q/' + req.body.text + format, pathname: 'http://api.wunderground.com/api/' + apikey + '/forecast/q/' + req.body.text + format,
...@@ -63,21 +65,20 @@ app.post('/post', function(req, res){ ...@@ -63,21 +65,20 @@ app.post('/post', function(req, res){
// Basic response for the conditions data already obtained // Basic response for the conditions data already obtained
var responseBody = { var responseBody = {
"response_type": "in_channel", "response_type": "in_channel",
"icon": icon_url, "text": '**' + location + "**\n" + obsLocation + ' (' + stationID + ')',
"text": "Forecast",
"attachments": [ "attachments": [
{ {
"text": "Location: " + location + "\n" "text": "**Current conditions**\n"
+ "Temperature: " + temperature + "\n" + "Temperature: " + temperature + "\n"
+ "Condition: " + weatherCondition, + "Condition: " + weatherCondition,
"image_url": icon_url, "image_url": icon_url
} }
] ]
}; };
// If forecast wasn't available, return just the conditions // If forecast wasn't available, return just the conditions
if ( error || 200 !== response.statusCode ) { if ( error || 200 !== response.statusCode ) {
responseBody.attachments[1] = { "text":"Could not retrieve forecast" }; responseBody.attachments[1] = { "text": "Could not retrieve forecast" };
return res.send( responseBody ); return res.send( responseBody );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment