Charca / bootbot

Facebook Messenger Bot Framework for Node.js
MIT License
974 stars 253 forks source link

When does the `captured` is set ? Or what is the flow order? #141

Open efleurine opened 6 years ago

efleurine commented 6 years ago

I have those two pieces of codes

1 - In index.js

bot.on("message", (payload, chat, data) => {
  const { text } = payload.message;
  console.log("in on ", new Date(), data); // 1
  chat.say(`Echo: ${text}`); // line 2
});

bot.module(generalModule);

and in module

 bot.hear("/about", (payload, chat, data) => {
    // Send Help Menu to the user...
    console.log("in general", data); // line 3
    chat.say(answer["/about"]); // line 4 awswer["/about"] = 'something'
  });

I try it many times and most of the times the on message would appear first. But sometimes the hear message would appear before it (happen rarely but happen). I tried to register the module first but this does not change anything. So Is there a way to enforce a particular order ?

HellCatVN commented 6 years ago

I think it happen disorder because async feature of javascript