olexnzarov / telegraf-session-mongodb

MongoDB session middleware for Telegraf
25 stars 14 forks source link

TypeError: Cannot read property 'id' of undefined in getSessionKey #12

Closed WithMistake closed 3 years ago

WithMistake commented 3 years ago

My bot is broken with this error. I analize why is problem coming and found.

Telegram add to update for bot 9 March 2021

Added two new update types Added updates about member status changes in chats, represented by the class ChatMemberUpdated and the fields my_chat_member and chat_member in the Update class. The bot must be an administrator in the chat to receive chat_member updates about other chat members. By default, only my_chat_member updates about the bot itself are received.

And this Context doesn't have id. So must be fixed for this new update

olexnzarov commented 3 years ago

Hey.

What Telegraf and telegraf-session-mongodb versions are you using?

WithMistake commented 3 years ago

I use "telegraf-session-mongodb": "1.3.1", because I use Telegraf 3 version.

aaugmentum commented 3 years ago

I have the same issue.

olexnzarov commented 3 years ago

I've published 1.3.2 version that allows you to provide a custom function for a session key creation.

For more details or implementation see this: https://github.com/alexnzarov/telegraf-session-mongodb/blob/legacy/README.md

WithMistake commented 3 years ago

Alex is good add custom function, but I think it must be work without custom function too. Maybe I create pull request for this?

olexnzarov commented 3 years ago

You can create a pull request with this fix, but I strongly advise you to upgrade Telegraf and this package in order to avoid future Telegram Bot API changes that can break this middleware.