我正在 nodejs 中开发一个 Telegram 机器人。我创建了一个 node-telegram-bot-api 实例,并使用 on('photo') 方法来管理用户是否向我的机器人发送照片。
问题是当用户通过从图库中多选照片来发送多张照片时,因为我的机器人响应的次数与发送的照片一样多。我认为这是因为机器人执行 on('photo') 方法的次数与发送的照片一样多。
bot.on('photo', function (msg) {
var fileId = msg.photo[2].file_id;
bot.downloadFile(fileId, folder);
bot.sendMessage(chatId, "I got the photo", keyboard);
bot.sendMessage(chatId, "Do you want to go to the next step of the procedure?", keyboard);
//I would like that the bot sends the last message only once
我希望机器人只响应一次。
你有什么建议吗?