I want to create a bot that sends out a tweet everyday at 11:11. However, the code that I have written only runs once when I type in command node bot.js, it does not run after that. I did not create an object Job since the documentation says I can run scheduleJob() without creating the object manually.
var schedule= require('node-schedule');
var writeTweet = function() {
Twitter.post('statuses/update', {
status: messages[messageLocation]
}, function(err, data, response) {
console.log(data)
});
messageLocation += 1;
}
var j=schedule.scheduleJob('11 11 * * *',writeTweet());```
It seems you are calling the function writeTweet()
in your scheduleJob
Where as you just need to pass a function.
Like this:
var j=schedule.scheduleJob('11 11 * * *',writeTweet);
Check this out: https://www.npmjs.com/package/node-schedule