make it so

This commit is contained in:
mannynotfound
2016-06-12 14:28:23 -04:00
commit 99839c17ec
4 changed files with 102 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
config*
node_modules/
npm-debug.log

32
README.md Normal file
View 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
View 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
View 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"
}
}