Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate messages if the method is called multiple times?
Libraries: python-telegram-bot-api
I have a script (bot) that listens for messages when you send a photo to it - it enters it into the database, and then takes it out of the database and sends it to another user.
The problem is, if the user sends several photos at once (album), the bot still sees them in the logs as several messages (conditionally, it breaks the album into pieces), and since I have a method call in the image processing method, due to the fact that I send several photos, the bot duplicates the messages with this method.
How can this be bypassed? In order for him to get all the photos, bring them in, and only then call the method (the number of photos can be different), I tried to make some crutches, but they rather aggravated the code than corrected it.
@bot.message_handler(content_types=['photo'])
def get_photo_messages(message):
try:
Вносим в базу (складываем file-id каждого фото)
Мой метод()
except Exception as e:
print(e)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question