Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
veryoldtweets.js
var _ = require('underscore');
_.mixin( require('underscore.deferred') );
var Twit = require('twit');
var T = new Twit(require('./config.js'));
var wordfilter = require('wordfilter');
Array.prototype.pick = function() {
return this[Math.floor(Math.random()*this.length)];
};
Array.prototype.pickRemove = function() {
var index = Math.floor(Math.random()*this.length);
return this.splice(index,1)[0];
};
function search() {
console.log('searching',term);
var dfd = new _.Deferred();
T.post('statuses/retweet/' + Math.floor(Math.random()*7500), { }, function(err, reply) {
console.log('error:',err);
var tweets = reply;
console.log(tweets);
dfd.resolve(tweets);
});
return dfd.promise();
}
function tweet() {
search().then(function(myTweet) {
if (!wordfilter.blacklisted(myTweet)) {
console.log(myTweet);
/*
T.post('statuses/update', { status: myTweet }, function(err, reply) {
if (err) {
console.log('error:', err);
}
else {
console.log('reply:', reply);
}
});
*/
}
});
}
// Tweet once on initialization
tweet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment