Skip to content

Instantly share code, notes, and snippets.

@thoragio
Last active July 22, 2017 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoragio/04b138bd5144f78f065d4f46ae4e4ac6 to your computer and use it in GitHub Desktop.
Save thoragio/04b138bd5144f78f065d4f46ae4e4ac6 to your computer and use it in GitHub Desktop.
Nuke Your Twitter History
# Grab the keys from Twitter Apps: https://apps.twitter.com/
CONSUMER_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
require('dotenv').config();
module.exports = {
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token: process.env.ACCESS_TOKEN,
access_token_secret: process.env.ACCESS_TOKEN_SECRET
};
/*
Nuke the history of tweets and favorites
Run the script a few times if you have a lot of history
This runs with node and the following dependencies:
"dotenv": "^4.0.0"
"twit": "^2.2.5"
*/
const Twit = require('twit');
const config = require('./config');
const bot = Twit(config);
/*
Nuke all tweets...
*/
const deleteTweet = id => {
bot.post(
'statuses/destroy',
{
id
},
(err, data, response) => {
if (err) {
console.log(err);
} else {
console.log('destroyed ' + id);
}
}
);
}
bot.get(
'statuses/user_timeline',
{
count: 1000,
screen_name: '[YOUR_SCREEN_NAME]'
},
(err, data, response) => {
if (err) {
console.log(err);
} else {
data.forEach(t => {
console.log(t.id_str);
deleteTweet(t.id_str);
});
}
}
);
/*
And favorites...
*/
const deleteFavorite = id => {
bot.post(
'favorites/destroy',
{
id
},
(err, data, response) => {
if (err) {
console.log(err);
} else {
console.log('destroyed ' + id);
}
}
);
}
bot.get(
'favorites/list',
{
count: 200,
screen_name: '[YOUR_SCREEN_NAME]'
},
(err, data, response) => {
if (err) {
console.log(err);
} else {
data.forEach(t => {
console.log(t.id_str);
deleteFavorite(t.id_str);
});
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment