我正在使用带有“ Twit”(npm)的node.js创建一个机器人,并且我试图使其在检测到时回复主题标签。但是我需要每隔一分钟就做一次,以避免instagram被禁止。我是新手,请原谅我的代码...并感谢您的帮助!
为了以防万一,我尝试使用setTimeout或serInterval,但是它不起作用...我需要它在上一分钟后一分钟回复每条推文
const term = ['#Example']
var stream = T.stream('statuses/filter', { track: term} );
var myUser = null
T.get('account/verify_credentials', { skip_status: true }, function(err, data, response) {
myUser = data.screen_name;
console.log('Using account ' + myUser );
});
var answerCap1Array = ["Example answer 1 ",
"Example answer 2 ",
"Example answer 3 "];
stream.on('tweet', eventTweeting);
function eventTweeting(tweet) {
if(
!tweet.retweeted_status
&&
tweet.user.screen_name !== myUser
){
tweetAnswer(tweet)
}
function tweetAnswer(tweet){
var replyto = tweet.in_reply_to_screen_name;
var text = tweet.text;
var user= tweet.user.screen_name;
var screenName = tweet.source.screen_name;
const videoCap1 = ' a youtube video'
var answer = '@' + user + ' ' + answerCap1Array[Math.floor(Math.random() * answerCap1Array.length)] + videoCap1
T.post('statuses/update', {
in_reply_to_status_id:tweet.id_str,
status:answer
}, done)
function done(){
console.log('done!');
}
}
}