Last active
December 10, 2016 11:01
-
-
Save phocks/302dee77b50525d1f6df7352bd660a8b to your computer and use it in GitHub Desktop.
Node script that mutes all the people you are following on Twitter
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
// npm install twit | |
var Twit = require('twit') | |
// Get these from apps.twitter.com | |
var T = new Twit({ | |
consumer_key: 'put your consumer key here', | |
consumer_secret: 'put your consumer secret here', | |
access_token: 'put your access token here', | |
access_token_secret: 'put your access token secret here', | |
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests. | |
}) | |
var count = 0; | |
var cursor = -1; | |
function doStuff() { | |
T.get('friends/list', { cursor: cursor, count: 200 }, function (error, data, response) { | |
if (error) console.log(error); | |
else { | |
console.log(data.next_cursor); | |
cursor = data.next_cursor; | |
function doSmallerStuff() { | |
console.log("#" + count); | |
console.log("Muted? " + data.users[count].muting); | |
if (!data.users[count].muting) { | |
console.log("Attempting to mute: " + data.users[count].screen_name) | |
T.post('mutes/users/create', { screen_name: data.users[count].screen_name }, function (error, data, response) { | |
if (error) console.log(error); | |
}); | |
} | |
count++; | |
if (count > 199) { | |
clearInterval(smallerStuffTimer); | |
count = 0; | |
} | |
} | |
doSmallerStuff(); | |
var smallerStuffTimer = setInterval(doSmallerStuff, 10); | |
} | |
}); | |
} | |
doStuff(); | |
var myTimer = setInterval(doStuff, 10*1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment