I'm making a Q&A twitter bot w twitter api using direct messages, my problem is each time a user ask a question, after a while, the bot start to response twice the same answers. Is there a way to limit each response to 1 API Call?
here my code:
stream.on('direct_message', function (eventMsg) {
var msg = eventMsg.direct_message.text;
var screenName = eventMsg.direct_message.sender.screen_name;
var msgID = eventMsg.direct_message.id_str;
if (screenName === ‘MyBotExample) {
return callbackHandler(msgID);
}
else if (msg.search(‘Hi’) !== -1 ) {
return T.post('direct_messages/new', {
screen_name: screenName,
text: 'Hey, what can I do for you?'} , function () {
callbackHandler(msgID);
});
}
else {
return T.post('direct_messages/new', {
screen_name: screenName,
text: "I don't know "
}, function() {
callbackHandler(msgID);
});
}
});
Thanks!
via Isaac
No comments:
Post a Comment