Something went wrong. Try again.
A Twitter-Bot that is going to increase your followers.
Something went wrong. Try again.
2.6 kB · 88 lines
JavaScript
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
// Dependencies =========================var twit = require('twit'), config = require('./config');
var Twitter = new twit(config);
// RETWEET BOT ==========================
// find latest tweet according the query 'q' in paramsvar retweet = function() { var params = { q: '#covid, covid', // REQUIRED result_type: 'recent', lang: 'en' } Twitter.get('search/tweets', params, function(err, data) { // if there no errors if (!err) { // grab ID of tweet to retweet var retweetId = data.statuses[0].id_str; // Tell TWITTER to retweet Twitter.post('statuses/retweet/:id', { id: retweetId }, function(err, response) { if (response) { console.log('Retweeted!!!'); } // if there was an error while tweeting if (err) { console.log('Something went wrong while RETWEETING... Duplication maybe...'); } }); } // if unable to Search a tweet else { console.log('Something went wrong while SEARCHING...'); } });}
// grab & retweet as soon as program is running...retweet();// retweet in every 2 minutesetInterval(retweet, 20000);
// FAVORITE BOT====================
// find a random tweet and 'favorite' itvar favoriteTweet = function(){ var params = { q: '#covid19, coronavirus', // REQUIRED result_type: 'recent', lang: 'en' } // find the tweet Twitter.get('search/tweets', params, function(err,data){
// find tweets var tweet = data.statuses; var randomTweet = ranDom(tweet); // pick a random tweet
// if random tweet exists if(typeof randomTweet != 'undefined'){ // Tell TWITTER to 'favorite' Twitter.post('favorites/create', {id: randomTweet.id_str}, function(err, response){ // if there was an error while 'favorite' if(err){ console.log('CANNOT BE FAVORITE... Error'); } else{ console.log('FAVORITED... Success!!!'); } }); } });}// grab & 'favorite' as soon as program is running...favoriteTweet();// 'favorite' a tweet in every 2 minutesetInterval(favoriteTweet, 20000);
// function to generate a random tweet tweetfunction ranDom (arr) { var index = Math.floor(Math.random()*arr.length); return arr[index];};