Skip to content

Instantly share code, notes, and snippets.

@ym
Created June 8, 2013 08:12
Show Gist options
  • Select an option

  • Save ym/5734491 to your computer and use it in GitHub Desktop.

Select an option

Save ym/5734491 to your computer and use it in GitHub Desktop.
删推利器。
var util = require('util'),
twitter = require('twitter'),
colors = require('colors');
var twit = new twitter({
consumer_key: '*',
consumer_secret: '*',
access_token_key: '*',
access_token_secret:'*'
});
String.prototype.has = function(strs) {
var str = this.trim().toLowerCase();
for (var i = 0; i < strs.length; i++) {
if(str.indexOf(strs[i].toLowerCase()) !== -1) {
return true;
}
}
return false;
}
var delete_tweet = function (id_str) {
twit.post('/statuses/destroy/' + id_str + '.json', {}, function (data) {
if(data.text) {
console.log(('Removed tweet ' + data.text.italic + '(id=' + id_str.bold + ')').red);
}
});
} , process_tweets = function (data) {
var id = '';
if(!data.length) {
return false;
}
console.log(('Got ' + data.length.toString().bold + ' tweets').blue);
for (var i = 0; i < data.length; i++) {
delete_tweet(data[i].id_str);
id = data[i].id_str;
}
return id;
} , fuck = function(last) {
var opt = {
screen_name: 'AvelineSwan',
include_entities: false,
contributor_details: false,
exclude_replies: false,
count: 200,
include_rts: true
};
if(typeof last != 'undefined') {
opt.max_id = last;
console.log(('Read tweets (id < ' + last.toString().bold + ')').magenta);
}
twit.get('/statuses/user_timeline.json', opt, function(data) {
var id = process_tweets(data);
if(id === false) {
console.log('Done'.green);
return false;
}
fuck(id);
});
}
fuck();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment