I have a Google spreadsheet with 4 rows, and I want to iterate through them one at a time every hour. The current code works but posts all four rows at the same time. How can I post one row every hour continuously?
require('console-stamp')(console, {
pattern: 'dd/mm/yyyy HH:MM:ss.l'
});
var Twit = require('twit');
var config = require('./dmconfig');
var Tabletop = require('tabletop');
var bot = new Twit(config);
var spreadsheetUrl = 'https://docs.google.com/spreadsheets/d/1234567/edit?usp=sharing';
var link = () => {
Tabletop.init({
key: spreadsheetUrl,
callback(data, tabletop) {
data.forEach(d => {
var status = d.tweetMsg + ' ' + Math.floor(Math.random() * 10000) + ' ' + d.userURL + ' via @AlDerbyshireG';
console.log(status)
bot.post('statuses/update', {
status
},
(err, response, data) => {
if (err) { console.log(err) }
else { console.log('Post success!') }
});
});
},
simpleSheet: true
});
}
link()
setInterval(link, 1000 * 60 * 60)