telegram-bot-ruby icon indicating copy to clipboard operation
telegram-bot-ruby copied to clipboard

The unhandled exception with supergroups

Open Spalf opened this issue 9 years ago • 2 comments

After update group to supergroup with bot: ruby/2.2.0/gems/telegram-bot-ruby-0.4.2/lib/telegram/bot/api.rb:56:incall': Telegram API has returned the error. (ok: "false", error_code: "400", description: "[Error]: Bad Request: group chat is migrated to supergroup chat", parameters: "{"migrate_to_chat_id"=>-*****************}") (Telegram::Bot::Exceptions::ResponseError)`

Spalf avatar Apr 07 '16 19:04 Spalf

I am having the same issue. Correct me if I am wrong, but the way I understand it, is that this error occurs only if a group is upgraded to a supergroup while the bot is a member of the group. (If a bot is added to an existing supergroup this does not occur)

When a group is migrated to a supergroup, it gets a new chat_id that is passed to the bot in the group in the field migrate_to_chat_id. This is now the chat_id that the bot should use to send messages in the group. By using the old one, we get that kind of error.

@atipugin will you be adding the ability to handle the upgraded to supergroup service message to the gem?

arnoldtonderaimarunda avatar Jun 09 '16 00:06 arnoldtonderaimarunda

I'm not sure how to handle it. Resend message with new chat_id? What if you store your chat ids somewhere in db? In this case you need to handle it by your own.

atipugin avatar Jun 09 '16 08:06 atipugin

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]