Skip to content

Instantly share code, notes, and snippets.

@ngs
Created July 14, 2014 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngs/98d49a2d17da344e615f to your computer and use it in GitHub Desktop.
Save ngs/98d49a2d17da344e615f to your computer and use it in GitHub Desktop.
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