-2
I’m creating a bot on Twitter to respond every time it’s mentioned with random text. It’s working fine, but the problem is that the API returns the "Status is a Duplicate".
This is the part that randomly chooses the texts that are in an array to publish, but I don’t think the error is in it:
var exibir = message[Math.floor((Math.random() * message.length))];
And that’s the finding, filtering and replying part:
Bot.get("search/tweets", { q: 'hey @namebot' }, (err, data) => {
if (err) {
console.log(err.message);
} else {
var tweetId = data.statuses[0].id_str;
var username = data.statuses[0].user.screen_name;
var tweetsRespondidos = [];
var i = 1;
if (tweetsRespondidos.includes(tweetId)) {
console.log('Esse tweet já foi respondido!');
} else {
Bot.post('statuses/update', {
in_reply_to_status_id: tweetId,
screen_name: username,
status: @ ${username} ${exibir}
}, function(err) {
if (err) {
console.log(err.message);
} else {
console.log('Resposta enviada! ');
tweetsRespondidos[i] = tweetId;
i++;
}
})
}
}
})
Give a
console.log
to see what status he is going through and to be able to better understand how he is being duplicated. No serious accent is missing\`` no
status: @${username} ${view}`?– Rafael Tavares
I fixed the seats, but there was no difference. in the log console I went to see and the status are in fact sending the same single text several times to the same tweet. when a new mention appears the bot manages to send a random text as 'hi', and then repeats the 'hi' until another different mention appears and it generates a 'hey', which also repeats...
– akemi