RealSpeaker / telegraf-session-local

Telegraf local sessions middleware with multiple supported storage types (Memory/FileSync/FileAsync/...) using lowdb
https://git.io/v7iw9
MIT License
93 stars 10 forks source link

created session value is missing on the "poll_answer" ctx #108

Closed Quernest closed 3 years ago

Quernest commented 3 years ago

Hey 🙋🏼‍♂️,

I faced such issue: I can't get the session object on the poll_answer ctx which is triggered after selecting an option in the quiz.

  // command for sending quiz
  bot.command('quiz', async (ctx) => {
    // ✅ create session object with counter
    ctx.session = { counter: 0 };

    ctx.telegram.sendQuiz(args);
    return ctx;
  });

  bot.on('poll_answer', async (ctx) => {
    console.log(ctx.session); // ⛔️ undefined, unable to increment counter
    return ctx;
  });
Quernest commented 3 years ago

Most likely this issue in the telegraf, so I opened it here: https://github.com/telegraf/telegraf/issues/1302