我正在使用这个 api:https ://github.com/orzFly/node-telegram-bot
它应该像其他任何东西一样工作。
现在我希望我的 Bot 可以选择更新他出于某种原因保留的字符串。依此类推“/update”更新函数被调用,其中msg是一个 Message 对象(https://core.telegram.org/bots/api#message):
link = "something";
function update(msg) {
response = tg.sendMessage({
text: "Send a new URL, please",
chat_id: msg.chat.id,
reply_to_message_id: msg.message_id,
reply_markup: {
force_reply: true,
selective: true
}
});
console.log("response: " + response);
// on reply I want to update link
}
现在这个机器人要求我提供一个新字符串。由于 force_reply,电报中的下一个答案已经是对机器人请求的答案。我怎么会得到这个答案?这里的“响应”是一个承诺对象,我不知道如何处理它。
在阅读了 Promises 对象之后,我尝试了这样的事情:
response.then(function successHandler(result) {
tg.sendMessage({
text: "new URL is: I don't know",
chat_id: msg.chat.id
});
}, function failureHandler(error) {
colsole.log("error: " + error);
});
但它没有用。绝不。
我只是不知道从哪里得到回复消息对象。我希望很清楚我在问什么。否则让我知道。