mirror of
https://github.com/thewesker/delete-trump.git
synced 2025-12-20 04:21:16 -05:00
make it so
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
config*
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
32
README.md
Normal file
32
README.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<p align="center">
|
||||||
|
<br />
|
||||||
|
<img src="https://raw.githubusercontent.com/mannynotfound/delete-trump/master/delete-trump.png" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# delete-trump
|
||||||
|
|
||||||
|
Automatically tell Donal Trump to delete his account.
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
|
||||||
|
Obligatory `npm install`
|
||||||
|
|
||||||
|
Put your [Twitter App credentials](http://iag.me/socialmedia/how-to-create-a-twitter-app-in-8-easy-steps/) inside the `config.json` file.
|
||||||
|
|
||||||
|
eg:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"api": {
|
||||||
|
"consumer_key": "1232131ixsad123",
|
||||||
|
"consumer_secret": "sad0123102391039da01",
|
||||||
|
"access_token_key": "lolololoalseowoakdsa",
|
||||||
|
"access_token_secret": "102391siadonanddadadasa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then simply run `npm start`.
|
||||||
|
|
||||||
|
To run continously, use `npm run start-forever`
|
||||||
|
|
||||||
52
app.js
Normal file
52
app.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
var config = require('./config.json');
|
||||||
|
var Twitter = require('twitter');
|
||||||
|
|
||||||
|
function DeleteTrump(api) {
|
||||||
|
this.client = new Twitter(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteTrump.prototype = {
|
||||||
|
startStream() {
|
||||||
|
var self = this;
|
||||||
|
this.client.stream('statuses/filter', {
|
||||||
|
'follow': '25073877'
|
||||||
|
}, function (stream) {
|
||||||
|
console.log('STARTING DYA STREAM .... ');
|
||||||
|
self.stream = stream;
|
||||||
|
stream.on('data', function (tweet) {
|
||||||
|
// only reply to tweets _from_ user
|
||||||
|
if (!tweet.user || tweet.user.screen_name !== 'realDonaldTrump') return;
|
||||||
|
|
||||||
|
self.client.post('statuses/update', {
|
||||||
|
'in_reply_to_status_id': tweet.id_str,
|
||||||
|
status: '.@realDonaldTrump Delete your account.'
|
||||||
|
}, function (err) {
|
||||||
|
if (err) handleError(err);
|
||||||
|
|
||||||
|
console.log('REPLIED TO TRUMP\'s TWEET ', tweet.text);
|
||||||
|
console.log('');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('error', self.handleError.bind(self));
|
||||||
|
stream.on('end', self.resurrect.bind(self));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
resurrect() {
|
||||||
|
this.stream = null
|
||||||
|
var self = this;
|
||||||
|
console.log('RESURRECTING STREAM');
|
||||||
|
setTimeout(function() {
|
||||||
|
self.startStream();
|
||||||
|
}, 1000 * 60 * 5 ); // wait 5 minutes
|
||||||
|
},
|
||||||
|
|
||||||
|
handleError(err) {
|
||||||
|
console.log(err);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var deleteTrump = new DeleteTrump(config.api);
|
||||||
|
deleteTrump.startStream();
|
||||||
15
package.json
Normal file
15
package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "delete-trump",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Automatically tell Trump to delete his account.",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node app",
|
||||||
|
"start-forever": "./node_modules/.bin/forever start app.js"
|
||||||
|
},
|
||||||
|
"author": "Manny404",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"forever": "^0.15.2",
|
||||||
|
"twitter": "^1.2.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user