-
-
Save brumm/2453e3fb80123f684737 to your computer and use it in GitHub Desktop.
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
# Description: | |
# hubot suggests a place to go for food | |
# | |
# Dependencies: | |
# node-foursquare-venues | |
# | |
# Configuration: | |
# configure your foursquare client id and secret and your location | |
# | |
# Commands: | |
# hubot food - returns a foursquare suggestion | |
# | |
# get it from: https://foursquare.com/developers/apps | |
clientId = '...' | |
clientSecret = '...' | |
ll = '50.92140559718036,6.959549188613892' # your lat and long | |
foursquare = new require('node-foursquare-venues')(clientId, clientSecret) | |
module.exports = (robot) -> | |
robot.respond /food/i, (msg) -> | |
search = | |
limit: 50 | |
radius: 800 | |
section: 'food' | |
openNow: true | |
ll: ll | |
foursquare.venues.explore search, (err, response) -> | |
return if response.meta.code != 200 | |
{ items } = response.response.groups[0] | |
suggestion = items[Math.floor(Math.random() * items.length)] | |
{ venue } = suggestion | |
{ name, location: {address} } = venue | |
url = "https://foursquare.com/v/#{venue.id}" | |
text = "how about: #{name}" | |
text += " on #{address}" if address | |
text += " - #{url}" | |
msg.send text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment