Skip to content

Instantly share code, notes, and snippets.

@Anaphase
Last active August 29, 2015 14:17
Show Gist options
  • Save Anaphase/e7af5a29b7bf60f89db2 to your computer and use it in GitHub Desktop.
Save Anaphase/e7af5a29b7bf60f89db2 to your computer and use it in GitHub Desktop.
var RedditStream, auth, comment_stream;
RedditStream = require('reddit-stream');
comment_stream = new RedditStream('comments', 'all', 'unique user agent for my-supercool-bot');
auth = {
username: 'my-supercool-bot',
password: 'password',
app: {
id: 'your-app-id',
secret: 'your-app-secret'
}
};
comment_stream.login(auth).then(function() {
console.log('logged in for comment stream');
comment_stream.start();
setTimeout(function() {
comment_stream.stop();
setTimeout(function() {
comment_stream.start();
}, 60 * 1000);
}, 60 * 1000);
}, function() {
console.log('failed to log in!');
});
comment_stream.on('new', function(comments) {
console.log('found', comments.length, 'comment(s)');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment