2017-03-13 2 views
0

나는 트위터 로봇을 가지고있는 프로젝트에서 일하고있다.개발자가 트위터를 Nodejs에 넣을 때 반복 응답

var replybot = function() { 
    //The word that we are going to search in tweets 
    var word = 'hello'; 
    //Variables to store the twitter user id and screen name to make a reply 
    var id_str, screen_name; 

    console.log('Bot started looking for the word ' + word + '.'); 
    stream.on('tweet', tweetEvent); 
    function tweetEvent(tweet) { 

     var info_text = tweet.text; 
     if (info_text.indexOf(word) > -1) { 
     console.log(tweet.text); //Displays the tweet with the word 
     //We store the twitter id and the user screen name to make a reply  
     id_str = tweet.id_str; 
     screen_name = tweet.user.screen_name; 
     console.log('need do it once'); 
     //Now we are going to reply the tweet 

     Twitter.post('statuses/update', {in_reply_to_status_id: id_str, 
     status: '@' + screen_name + ' I think you mean "goodbye"'}, 
     function(error, tweet, response){ 
      if(error) { 
       console.log(' Error'); 
      } 
      else{ 
       console.log('. Success!!!'); 
      } // Tweet body   
     }); 
    } 
    } 
    console.log('done'); 
    } 
    replybot(); 
    // 'reply' a tweet in every 25 minutes 
    setInterval(replybot, 1500000); 

임 작업이 REPO 다음 : https://github.com/ttezel/twit

여기 내 코드입니다.

하지만 문제가 생겼습니다. 위의 코드를 실행할 때 봇은 한 번의 트윗에서 많은 시간을 응답하며 그 이유를 모르겠습니다. 이 함수의 간격을 설정했지만.

노드와 어떤 새로운 도움이 될까요? 감사합니다

답변

0

아 내가 여기에 영원히 루프를 가지고 정말 미안 :

기능 (오류, 트윗, 응답)

이 안 트윗 인수