-
-
Save dariusk/354688ad99c77dfbe3a37302af68ea22 to your computer and use it in GitHub Desktop.
veryoldtweets.js
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
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