Last active
August 29, 2015 14:13
-
-
Save arlando/24078d06b2e3524297c5 to your computer and use it in GitHub Desktop.
twit sample
This file contains hidden or 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
var Twit = require('Twit'); | |
var config = { | |
//my config | |
}; | |
var T = new Twit(config); | |
var filterStream; | |
function filter() { | |
filterStream = T.stream('statuses/filter', openStreamOptions); | |
filterStream.on('tweet', function (tweet) { | |
//cache tweet | |
removeLastTweetAndNewTweetForOpenStream(tweet); | |
//emit the single tweet object | |
log('info', 'information stream received a tweet!'); | |
eventBus.emit(eventBusKeys.SOCKET_OPENSTREAM_UPDATE, tweet); | |
}); | |
filterStream.on('connect', function () { | |
log('info', 'information stream connecting...'); | |
}); | |
filterStream.on('disconnect', function (message) { | |
log('error', 'information stream disconnected with message: ' + message); | |
}); | |
filterStream.on('connected', function (response) { | |
log('info', 'information stream connected with response: ' + response.statusCode ); | |
}); | |
filterStream.on('reconnect', function () { | |
log('warn', 'information stream reconnecting'); | |
}); | |
filterStream.on('warning', function (message) { | |
log('warn', 'information stream warning: ' + message); | |
}); | |
} | |
module.exports = function () { | |
filter(); | |
return { | |
getCachedOpenStreamTweets: getCachedOpenStreamTweets | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment