1
如何调用并使用此函数仅用于1个时间和rhat杀死函数之后?
调用函数:运行一个函数只需一次
else if (msg.text == ["contact us"]) {
const opts = {
reply_to_message_id: msg.message_id,
reply_markup: JSON.stringify({
keyboard: arrangeKeyboard(locale.keyboards[msg.text].childs, 2, msg),
resize_keyboard: true,
one_time_keyboard: true
})
};
bot.sendMessage(msg.chat.id, "Please Write your Messages:", opts);
getmessage1();
}
这是我的功能,我不循环运行想,我需要发送一个信息,并中止功能。
var getmessage = async() => {
// Listen for any kind of message. There are different kinds of messages.
await new Promise((resolve, reject) => {
bot.on('message', (msg) => {
if (!locale.keyboards[msg.text] &&
!msg.text.includes("previous button")) {
console.log("user message is: " + msg.text)
const opts = {
reply_to_message_id: msg.message_id,
reply_markup: JSON.stringify({
keyboard: arrangeKeyboardWithOut(locale.keyboards["/start"].childs, 2, msg),
resize_keyboard: true,
one_time_keyboard: true
})
};
bot.sendMessage(msg.chat.id, ' your message recieved', opts);
}
resolve(true);
});
});
return
}
var getmessage1 = async() => {
await getmessage();
}
你想只听一次活动吗? –
我想要用户点击联系我们,并发送她的消息,过程完成,因为在这段代码中第一次是okey,在接下来的时间后,它可以接收每个按钮和每个菜单中的消息 –
你究竟是什么意思?功能?所以它只执行一次,如果你再次调用它什么也不做? –