Last active
August 29, 2015 14:02
-
-
Save cmcculloh/7d851d097c8c50f4e9d2 to your computer and use it in GitHub Desktop.
Twitter Getter - Blinking tweets on your sparkboard
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
//put this in a config/ directory | |
module.exports = { | |
io: { | |
token: '', | |
deviceId: '' | |
}, | |
twitter: { | |
consumer_key: '', | |
consumer_secret: '', | |
access_token_key: '', | |
access_token_secret: '' | |
} | |
} |
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
// Thanks to: | |
// https://github.com/desmondmorris/node-twitter | |
// https://github.com/Yahosh/noderboater/blob/master/app.js | |
// This code a quick hack and could use some refactoring... | |
// you'll need to run appropriate npm commands to install several of these | |
var Spark = require('spark-io'); | |
var util = require('util'); | |
var twitter = require('twitter'); | |
var config = require('config'); | |
var twit = new twitter(config.twitter); | |
var twit2 = new twitter(config.twitter); | |
var board = new Spark(config.io); | |
board.on("ready", function() { | |
console.log("CONNECTED"); | |
var onOff = 0; | |
this.pinMode("D0", this.MODES.OUTPUT); | |
this.pinMode("D1", this.MODES.OUTPUT); | |
var b = this; | |
twit.stream('filter', {track:'javascript,jsconf'}, function(stream) { | |
stream.on('data', function(data) { | |
if(!!data.text && data.text.toLowerCase().indexOf('javascript') > -1){ | |
console.log('javscript', data.text); | |
b.digitalWrite("D1", 1); | |
setTimeout(function() { | |
b.digitalWrite("D1", 0); | |
}.bind(this), 1000); | |
} | |
if(!!data.text && data.text.toLowerCase().indexOf('jsconf') > -1){ | |
console.log('jsconf', data.text); | |
b.digitalWrite("D0", 1); | |
setTimeout(function() { | |
b.digitalWrite("D0", 0); | |
}.bind(this), 1000); | |
} | |
}); | |
}); | |
}); | |
board.on("error", function(error) { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment