olexnzarov / telegraf-session-mongodb

MongoDB session middleware for Telegraf
25 stars 14 forks source link

Support session for callback and inline queries. #4

Closed barinbritva closed 4 years ago

barinbritva commented 4 years ago

I use inline queries and noticed, session doesn't work with it. In telegraf docs I found following information:

// Tip: To use same session in private chat with bot and in inline mode, use following session key resolver:
{
  getSessionKey: (ctx) => {
    if (ctx.from && ctx.chat) {
      return `${ctx.from.id}:${ctx.chat.id}`
    } else if (ctx.from && ctx.inlineQuery) {
      return `${ctx.from.id}:${ctx.from.id}`
    }
    return null
  }
}

Also I found a ready solution in telegraf-session-local and implemented similar solution.