How to use the bottender/router.router function in bottender

To help you get started, we’ve selected a few bottender examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yoctol / bottender / examples / todos / index.js View on Github external
module.exports = async function App(context) {
  return router([
    text('/list', withProps(ShowTodos, { todos: context.state.todos })),
    text('/clear', ClearTodos),
    text('*', AddTodo),
  ]);
};
github tigercosmos / vocabulary-titan / index.js View on Github external
async function HandleNumber(context) {
  const data = cache.get(context.state.word);

  if (context.state.word == '' || data === undefined) {
    return HintEnterNewWord;
  }

  const Router = router([
    text('1', HandleNumber1),
    text('2', HandleNumber2),
    text('3', HandleNumber3),
    text('4', HandleNumber4),
    text('5', HandleNumber5),
    text('*', HandleOtherNumber),
  ]);

  return withProps(Router, { data });
}
github tigercosmos / vocabulary-titan / index.js View on Github external
module.exports = async function App(context) {
  if (context.event.isFollow || context.event.isJoin) {
    return Greeting;
  }

  return router([
    text(/^h(ello|i)|^\/start/, Greeting),
    text('@@@', Diagnose),
    text(/^\d$/, HandleNumber),
    text(/^[a-zA-Z\s-]+$/, SearchWord),
    text('*', WrongInput),
  ]);
};