Skip to content

Instantly share code, notes, and snippets.

@bumi
Created August 25, 2014 12:22
Show Gist options
  • Save bumi/4bbac30e884f544f744e to your computer and use it in GitHub Desktop.
Save bumi/4bbac30e884f544f744e to your computer and use it in GitHub Desktop.
a hubot script that suggest you a place to go for food near your place. - no more discussions on where to go for lunch in the office. :)
# 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) ->
if response.meta.code != 200
return
items = response.response.groups[0].items
suggestion = items[Math.floor(Math.random() * items.length)]
venue = suggestion.venue
name = venue.name
address = venue.location.address
url = "https://foursquare.com/v/#{venue.id}"
text = "how about: #{name}"
if address
text = text + " on #{address}"
text = text + " - #{url}"
console.log(text)
msg.send text
@bumi
Copy link
Author

bumi commented Aug 26, 2014

pro tip: add msg.send "http://aufnahme.com/happahappa.gif" to get some @railsbros-dirk love in your chat

happa

@DonSchado
Copy link

so awesome! 👯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment