Hey everybody,
Apologies if this question is not in the correct section.
I’m working on a project where I have a twitter bot that tweets(Not as a reply) every time a certain account tweets.
I can get it working when I set up a test account but when I do it with the real account (a popular one) my bot will just keep tweeting continuously and not when the specified account tweets.
I am basing my code on Daniel Shiffman’s twitter bot tutorials on YouTube:
My Code is below:
console. log('The streambot is starting');
var Twit = require('twit');
var config = require('./config');
var T = new Twit(config);
var stream = T.stream('statuses/filter', { follow: '(//TWITTERID OF ACCOUNT GOES HERE' });
stream.on('tweet',thisTweet);
function thisTweet(){
var randomWords= "//a list of random words"
var splitrandom = randomWords.split(",");
//picks a random word from list
var oneWord = splitrandom [Math.floor(Math.random() * splitrandom .length)];
tweetIt(oneWord);
}
function tweetIt(txt){
var tweet = {
status : txt
}
T.post('statuses/update',tweet,tweeted);
}
function tweeted(err, data, response) {
if (err){
console.log("something went wrong!");
}else{
console.log("It Worked");
}
}
Any help would be great!
P.S I should also mention that I am doing this through node, javascript using the Twit API…but if anyone else has other suggestions to achieve the same thing I’ll happily try them.