Created
August 20, 2020 16:25
-
-
Save staccDOTsol/67ec7dc17e50f2dea2080c9159591be6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request') | |
var parseString = require('xml2js').parseString; | |
towrite = [] | |
var Twitter = require('twitter'); | |
var client = new Twitter({ | |
consumer_key: '', | |
consumer_secret: '', | |
access_token_key: '', | |
access_token_secret: '' | |
}); | |
function doget(){ | |
request.get("https://medium.com/feed/@jarettdunn", function (e, r, d){ | |
parseString(d, function (err, result) { | |
items = result.rss.channel[0].item | |
towrite = [] | |
for (var i in items){ | |
if (items[i].category != undefined){ | |
towrite.push(new Date().toString().substring(8,10)+ new Date().toString().substring(15,21) + ' #amwriting #medium ' + items[i].title + ' ' + items[i].link.toString().split('?source')[0] + ' #' + items[i].category.toString().split(',').join(' #')) | |
} | |
} | |
for (var tw in towrite){ | |
towrite[tw] = (towrite[tw] + " #Medium #AmWriting #WritingCommunity #inspiration #writers #writersnetwork #author #readers").substring(0, 279) | |
console.log(towrite[tw].length) | |
} | |
random = Math.floor(Math.random(0) * towrite.length) | |
console.log('random ' + random.toString()) | |
client.post('statuses/update', {status: towrite[random]}, function(error, tweet, response) { | |
if(error) throw error; | |
console.log(tweet); // Tweet body. | |
console.log(response); // Raw response object. | |
}); | |
}); | |
}) | |
} | |
doget() | |
setInterval(function (){ | |
doget() | |
}, 60 * 60 * 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment