Created
June 8, 2013 08:12
-
-
Save ym/5734491 to your computer and use it in GitHub Desktop.
删推利器。
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 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