Wednesday, 3 May 2017

Run A Function just for one Time

How Can I Call And Use This Function Just For 1 Time and after That kill The Function? Calling The Function

getmessage1();

This is My Function and I don't want run in a loop,I need to send a message and kill function.

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();
}



via Sedric Heidarizarei

No comments:

Post a Comment