Skip to content

Instantly share code, notes, and snippets.

@brumm
Forked from bumi/food.coffee
Last active August 29, 2015 14:05
Show Gist options
  • Save brumm/2453e3fb80123f684737 to your computer and use it in GitHub Desktop.
Save brumm/2453e3fb80123f684737 to your computer and use it in GitHub Desktop.
# 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