Skip to content

Instantly share code, notes, and snippets.

@holman
Created November 5, 2014 05:35
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holman/55130df8c9ba9fbce085 to your computer and use it in GitHub Desktop.
Save holman/55130df8c9ba9fbce085 to your computer and use it in GitHub Desktop.
A quick Hubot script to display Uber surge pricing from a particular point (LIKE AN OFFICE).
# Description
# Uber surge pricing magic checker.
#
# Commands:
# hubot uber me - Show the surge pricing information from the SF office.
Table = require 'cli-table'
module.exports = (robot) ->
robot.respond /uber me/i, (msg) ->
params =
'server_token': "#{process.env.HUBOT_UBER_TOKEN}"
'start_latitude': 37.782093 # this'll take you from the GitHub office, sooooo
'start_longitude': -122.391580 # your mileage (haha good one holman!) may vary
'end_latitude': 37.786959
'end_longitude': -122.397803
msg.http("https://api.uber.com/v1/estimates/price").query(params).get() (err, res, body) ->
table = new Table
head: ['phat ride', 'surge pricing'],
style: { head: false, border: [] }
json = JSON.parse(body)
for product in json["prices"]
table.push [product["display_name"], product["surge_multiplier"]]
msg.send "#{table}"
@fwenzel
Copy link

fwenzel commented Nov 5, 2014

YMMV - I see what you did there

@maxbeatty
Copy link

I really liked this idea so I fleshed it out a bit

https://github.com/maxbeatty/hubot-uber

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