Do telegram chat IDs stay the same when converting to a supergroup?

后端 未结 1 1455
生来不讨喜
生来不讨喜 2021-01-14 15:45

On Telegram, every group has a chat-id that my bot saves whenever it is added to a group.

If an owner of a group converts it to a supergroup, will the I

相关标签:
1条回答
  • 2021-01-14 16:45

    After testing it out for myself, the chat-id does change on migration to a supergroup.

    However I found the following way, using python-telegram-bot to keep your chat-ids updated:

    def migchat(bot, update):
      oldchatid = update.message.migrate_from_chat_id
      newchatid = update.message.chat.id
      # process those values as needed (e.g. update a database)
    
    dispatcher.add_handler(MessageHandler(Filters.status_update.migrate, migchat))
    

    This uses the Filters submodule to call migchat whenever a chat is being migrated.

    This is how the JSON response of the message from the /getUpdates call looks like:

    0 讨论(0)
提交回复
热议问题