Created
April 27, 2016 06:55
-
-
Save jackrobotics/e05cb3460d635b48881d3f98234ed2f7 to your computer and use it in GitHub Desktop.
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
/* | |
Requirement NODEJS | |
- facebook-chat-api | |
- microgear | |
*/ | |
/* ### START CONFIG ### */ | |
var facebookEmail = 'email'; | |
var facebookPassword = 'pass'; | |
//NETPIe | |
const KEY = "d0B0ucFscjERJ6ER"; | |
const SECRET = "R3n0XQGPRxZt2gsvxrPDusSRC2axjU7"; | |
const APPID = "myROOM"; | |
const NETPieSERAlias = "myROOM" | |
/* ### END CONFIG ### */ | |
var login = require("facebook-chat-api"); | |
login({email: facebookEmail, password: facebookPassword}, function callback (err, api) { | |
if(err) return console.error(err); | |
api.listen(function callback(err, message) { | |
if(message.body.match(/turn on/gi)){ | |
microgear.chat('myRoom', 'ON'); | |
}else if(message.body.match(/turn off/gi)){ | |
microgear.chat('myRoom', 'OFF'); | |
} | |
}); | |
}); | |
var MicroGear = require('microgear'); | |
var microgear = MicroGear.create({ | |
key : KEY, | |
secret : SECRET | |
}); | |
microgear.on('connected', function() { | |
console.log('NETPie Connected...'); | |
microgear.setalias(NETPieSERAlias); | |
setInterval(function() { | |
//microgear.chat('mygear', 'Hello world.'); | |
},1000); | |
}); | |
microgear.on('message', function(topic,body) { | |
console.log('incoming : '+topic+' : '+body); | |
}); | |
microgear.on('closed', function() { | |
console.log('Closed...'); | |
}); | |
microgear.connect(APPID); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment