【发布时间】:2018-05-29 06:04:44
【问题描述】:
我正在尝试创建一个 twitter 机器人来仅转发父推文(IE 不回复其他推文或页面已转发的内容),我已设法阻止该机器人转发推文,但找不到任何关于如何停止的信息它转发对其他推文的回复,有人可以帮忙吗?
/requires twit module
var twit = require('twit');
//require the config.js file
var config = require('./config.js');
//pass key values from config to twit to allow it to tweet ect
var Twitter = new twit(config);
//query for tweets
var retweet = function() {
var params = {
//q is query, this one looks for tweets from city that are not retweets
q: 'from:@officialbantams -RT',
//makes sure to only retweet english twit
lang: 'en'
//I've commented this out but it filters for only retweeting a tweet posted since the last time the function ran
//result_type: 'recent',
}
// for more parametes, see:
https://dev.twitter.com/rest/reference/get/search/tweets
Twitter.get('search/tweets', params, function(err, data) {
// if there no errors
if (!err) {
// grab ID of tweet to retweet
var retweetId = data.statuses[0].id_str;
// Tell TWITTER to retweet
Twitter.post('statuses/retweet/:id', {
id: retweetId
//post in console that a tweet has been retweeted
}, function(err, response) {
if (response) {
console.log('Retweeted!!!');
}
// if there was an error while tweeting
if (err) {
console.log('Something went wrong while RETWEETING... Duplication maybe...');
}
});
}
// if unable to Search a tweet
else {
console.log('Something went wrong while SEARCHING...');
}
});
}
// grab & retweet as soon as program is running...
retweet();
// retweet in every 50 minutes (time is in ms so 100*60*number of minutes wanted
setInterval(retweet, 50*60*100);
【问题讨论】:
标签: javascript node.js twitter