Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BotBrother and asynchronous db #6

Closed
lsndr opened this issue Sep 26, 2016 · 1 comment
Closed

BotBrother and asynchronous db #6

lsndr opened this issue Sep 26, 2016 · 1 comment

Comments

@lsndr
Copy link

lsndr commented Sep 26, 2016

Is it possible to use asynchronous db with BotBrother. As I understood callbacks must always return promises. But when I want to get some information from db and send it to user I can't return "sendmessage promise". So it making imposible to use async dbs.

Am I right?

@SerjoPepper
Copy link
Owner

You can use any async db. Promise is one type of handy interface for async actions.

bot.command('start').invoke(function (ctx) {
  return new Promise(function (resolve) {
    query_to_your_db(function () {
      ctx.sendMessage(...).then(resolve)
    })
  })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants