Handling of ChatMigrated Errors #1684
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in the dev chat, I added a warning to
CC.chat_dataabout groups migrating to supergroup.To make handling of the status updates from Telegram possible, I added the dispatcher property to
CallbackContext.If merged, add this section to the wiki:
Chat Migration
If a group chat migrates to supergroup, its chat id will change. Since the
chat_datadicts are stored per chat id you'll need to transfer the data to the new id. Here are the two situations you may encounter:Status Updates sent by Telegram
When a group migrates, Telegram will send an update that just states the new info. In order to catch those, simply define a corresponding handler:
To be entirely sure that the update will be processed by this handler, either add it first or put it in its own group.
ChatMigrated Errors
If you try e.g. sending a message to the old chat id, Telegram will respond by a Bad Request including the new chat id. You can access it using an error handler:
Unfortunately, Telegram does not pass along the old chat id, so there is currently no simple way to perform a data transfer like above within the error handler. So make sure, that you catch the status updates! Still, you can wrap your requests into a
try-except-clause: