This commit is contained in:
thewesker
2016-06-18 02:11:22 -04:00
parent 5d3aadeabc
commit a8f0de0967
4 changed files with 35 additions and 7 deletions

22
config.json Normal file
View File

@@ -0,0 +1,22 @@
{
"trumpmessages": [
"Delete your account.",
"Trump smells bad.",
"You're gonna lose, cheeto monster!",
"HAHAHAHAHAHA",
"What a terrible tweet!",
"Nope!",
"Donald Dump",
"Tronald Dump"
]
"hillarymessages": [
"Release the Benghazi emails!",
"Where are the emails, Hillary?",
"Cillary Hlinton",
"We're on to you, Hillary!"
]
}

View File

@@ -5,8 +5,8 @@
"main": "test.js",
"dependencies": {
"fs": "^0.0.2",
"twauth": "^1.0.1",
"twit": "^2.2.4"
"twit": "^2.2.4",
"lowdb": "^0.12.5"
},
"devDependencies": {},
"scripts": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 830 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

14
test.js
View File

@@ -1,5 +1,8 @@
var Twit = require('twit')
var fs = require('fs')
var low = require('lowdb');
var storage = require('lowdb/file-sync');
var session = low('./config.json', {'storage': storage});
var T = new Twit({
consumer_key: 'XEpOzvNVnIL0z5cFggsZQzrTt',
@@ -15,6 +18,8 @@ var stream = T.stream('statuses/filter', { follow: '25073877, 1339835893, 216776
stream.on('tweet', function (tweet) {
if (tweet.user.screen_name === 'realDonaldTrump') {
var b64content = fs.readFileSync('./pics/trump.gif', { encoding: 'base64' })
var trumpmessages = session.object.trumpmessages;
var randomtrumpmessage = trumpmessages[Math.floor(Math.random() * trumpmessages.length)];
// first we must post the media to Twitter
T.post('media/upload', { media_data: b64content }, function (err, data, response) {
@@ -29,10 +34,10 @@ T.post('media/upload', { media_data: b64content }, function (err, data, response
T.post('media/metadata/create', meta_params, function (err, data, response) {
if (!err) {
// now we can reference the media and post a tweet (media will attach to the tweet)
var params = {in_reply_to_status_id: nameID, status: '@' + name + " Delete your account.", media_ids: [mediaIdStr] }
var params = {in_reply_to_status_id: nameID, status: '@' + name + ' ' + randomtrumpmessage, media_ids: [mediaIdStr] }
T.post('statuses/update', params, function (err, data, response) {
console.log("Replied to Trump's Tweet")
console.log("Replied to Trump's Tweet with " + randomtrumpmessage)
})
}
})
@@ -40,7 +45,8 @@ T.post('media/upload', { media_data: b64content }, function (err, data, response
}
if (tweet.user.screen_name === 'HillaryClinton') {
var b64content = fs.readFileSync('./pics/hillary.gif', { encoding: 'base64' })
var hillarymessages = session.object.hillarymessages;
var randomhillarymessage = hillarymessages[Math.floor(Math.random() * hillarymessages.length)];
// first we must post the media to Twitter
T.post('media/upload', { media_data: b64content }, function (err, data, response) {
// now we can assign alt text to the media, for use by screen readers and
@@ -57,7 +63,7 @@ T.post('media/upload', { media_data: b64content }, function (err, data, response
var params = {in_reply_to_status_id: nameID, status: '@' + name + " Release the Benghazi emails!", media_ids: [mediaIdStr] }
T.post('statuses/update', params, function (err, data, response) {
console.log("Replied to Hillary's Tweet")
console.log("Replied to Hillary's Tweet with " + randomhillarymessage)
})
}
})