mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 07:06:26 +01:00
Updated Storing bot, user and chat related data (markdown)
parent
3a626ad0b3
commit
b8f5e5ef91
1 changed files with 12 additions and 6 deletions
|
@ -103,11 +103,17 @@ async def my_callback(update, context):
|
|||
# Resend to new chat id
|
||||
await context.bot.send_message(new_id, text)
|
||||
|
||||
# Transfer data
|
||||
if chat_id in application.chat_data:
|
||||
application.migrate_chat_data(
|
||||
old_chat_id=chat_id,
|
||||
new_chat_id=new_id
|
||||
)
|
||||
# Get old and new chat ids
|
||||
old_id = message.migrate_from_chat_id or message.chat_id
|
||||
new_id = message.migrate_to_chat_id or message.chat_id
|
||||
|
||||
# transfer data, only if old data is still present
|
||||
# this step is important, as Telegram sends *two* updates
|
||||
# about the migration
|
||||
if old_id in application.chat_data:
|
||||
application.migrate_chat_data(
|
||||
old_chat_id=old_id,
|
||||
new_chat_id=new_id
|
||||
)
|
||||
...
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue