Created
July 14, 2014 15:05
-
-
Save ngs/98d49a2d17da344e615f to your computer and use it in GitHub Desktop.
2014/07/13 Romo Hackathon
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
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