From 99839c17ec6b459480a6b299a8b1937b197efc5c Mon Sep 17 00:00:00 2001 From: mannynotfound Date: Sun, 12 Jun 2016 14:28:23 -0400 Subject: [PATCH] make it so --- .gitignore | 3 +++ README.md | 32 ++++++++++++++++++++++++++++++++ app.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 15 +++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d71ecf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config* +node_modules/ +npm-debug.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..ceedba4 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +

+
+ +

+ +# 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` + diff --git a/app.js b/app.js new file mode 100644 index 0000000..8c1ae41 --- /dev/null +++ b/app.js @@ -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(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..d612af5 --- /dev/null +++ b/package.json @@ -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" + } +}