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

reply with poll bug #117

Closed
dimasxp opened this issue Dec 1, 2021 · 2 comments
Closed

reply with poll bug #117

dimasxp opened this issue Dec 1, 2021 · 2 comments

Comments

@dimasxp
Copy link

dimasxp commented Dec 1, 2021

when I submit a vote using the bot and the first person votes, I get the following error. looks like a bug?
the session in the bot is configured and works in all cases, except for this
CleanShot 2021-12-01 at 04 12 46@2x

@KnorpelSenf
Copy link
Member

This is not a bug in grammY. You are trying to access the session data while processing the update about the poll. However, session data is stored per chat. Poll updates do not reveal which chat they originate from. They only give you the poll identifier. This is because polls can be shared across chats and they display the same results everywhere.

Long story short: you cannot access the session data while handling that update, and that is what the error is trying to tell you—at least not with the default session key resolver. You can fix the error by either

  • not accessing ctx.session for that update, or
  • specifying getSessionKey for the session plugin and passing a function that can load and store session data in the case that the chat is not known, i.e. ctx.chat === undefined.

@dimasxp
Copy link
Author

dimasxp commented Dec 1, 2021

thanks for the explanation, it helped a lot.
it turned out to fix errors and catch poll updates 🙏
CleanShot 2021-12-01 at 05 20 09@2x

@dimasxp dimasxp closed this as completed Dec 1, 2021
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