Created
August 25, 2014 12:22
-
-
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. :)
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) -> | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pro tip: add
msg.send "http://aufnahme.com/happahappa.gif"
to get some @railsbros-dirk love in your chat