Search code examples
telegram-bot

telegram bot sending the same message again and again


I have built a telegram bot for my personal use and it was working as expected. But I sent a voice message (by mistake) and since then it has stopped working. I checked the logs and I can see that the same message_id is being sent to my server from telegram. Instead of plain text, it tries to send the same voice message like this...

{'update_id': 916674357, 'message': {'message_id': 26, 'from': {'id': 6718326872, 'is_bot': False, 'first_name': 'xxx', 'last_name': 'xxx', 'language_code': 'en'}, 'chat': {'id': 6718326872, 'first_name': 'xxx', 'last_name': 'xxx', 'type': 'private'}, 'date': 1710860131, 'voice': {'duration': 3, 'mime_type': 'audio/ogg', 'file_id': 'AwACAgUAAxkBAAMaZfmnY9NwoSN9gUTk9X-2IKrUR_kAAscQAAIpytBXzU25p9aDeoM0BA', 'file_unique_id': 'AgADxxAAAinK0Fc', 'file_size': 64763}}}

Solution

  • drop_pending_updates parameter can be used in telegram bot to reset pending messages like this...

    https://api.telegram.org/botYOURTOKEN/setWebhook?url=https://yoururl.com&drop_pending_updates=true