Whenever inline button clicked by user call back query send duplicate messages so what type of changes I need to do to bot not send duplicate messages.
var keyboard = [];
movieRatingList.map((movie, idx) => {
var movieRating = Math.round(movie.rating * 10) / 10;
if (movieRating == bestRating) {
var firstName = movieList[idx].firstName;
keyboard.push([{ text: firstName, callback_data: idx }]);
}
});
bot.sendMessage(userChatId, userText, {
reply_markup: JSON.stringify({
resize_keyboard: true,
inline_keyboard: keyboard,
}),
});
bot.on("callback_query", (callBackData) => {
var idx = Number(callBackData.data);
var fileID = movieList[idx].file_id;
var firstName = movieList[idx].firstName;
console.log(fileID);
console.log(firstName);
bot.sendDocument(userChatId, fileID, { caption: firstName });
});