Instantly share code, notes, and snippets.

Embed
What would you like to do?
2014/07/13 Romo Hackathon
apn = require 'apn'
options =
cert : './apn/cert.pem',
key : './apn/key.pem',
gateway : 'gateway.sandbox.push.apple.com',
port : 2195,
moveRomo = ->
apnConnection = new apn.Connection options
myDevice = new apn.Device process.env.ROMO_DEVICE_TOKEN
note = new apn.Notification()
note.expiry = Math.floor(Date.now() / 1000) + 3600 # Expires 1 hour from now.
note.badge = 0
note.alert = null
note.payload = {}
apnConnection.pushNotification note, myDevice
module.exports = (robot) ->
robot.respond /ngsromo\s+wakeup\s*$/, (msg)->
msg.reply 'Waking up ngsromo'
moveRomo()
robot.router.get '/ngsromo/yo', (req, res)->
user = robot.brain.userForName 'ngs'
room = process.env.ROMO_ROOM
robot.send { user, room }, "Received YO from #{req.query.username}. Waking up ngsromo"
moveRomo()
res.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment