This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var utilities = require('../utilities/utilities'); | ||
var config = require('../config/config'); | ||
|
||
exports.respond = function(bot, message, response) { | ||
if(!response.entities.location) { | ||
bot.reply(message, 'You need to specify an address, like this: ```123 some street```'); | ||
} | ||
else { | ||
var payload = { address: response.entities.location[0].value }; | ||
var url = config.apis.polling_location_url; | ||
utilities.postJson(bot, message, url, settings, payload, buildResonse); | ||
} | ||
} | ||
|
||
// Settings for use in rendering user response. | ||
var settings = {}; | ||
|
||
function buildResonse(bot, message, settings, error, response, body) { | ||
if(!error && response.statusCode == 200) { | ||
var place = body.features[0].attributes; | ||
bot.reply(message, 'Location: ' + place.location); | ||
bot.reply(message, 'Address: ' + place.display_address); | ||
bot.reply(message, 'Parking: ' + utilities.parkingCodeLookup(place.parking)); | ||
bot.reply(message, 'Accessibility: ' + utilities.buildingCodeLookup(place.building)); | ||
bot.reply(message, 'Map: https://www.google.com/maps/place/' + encodeURIComponent(place.display_address + ', Philadelphia, PA')); | ||
|
||
} | ||
else { | ||
bot.reply(message, 'Sorry, I could not look up polling location for that address.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters