D
D
dead_archee2020-11-15 16:26:43
Python
dead_archee, 2020-11-15 16:26:43

Why telegram bot doesn't send audio files?

It gives an error when trying to send 7 audio files, but when sending two, everything works ... I don’t understand what the error is? I'm just a beginner and I seem to have done everything right. The following error is thrown:

(util.py:75 WorkerThread1) ERROR - TeleBot: "ConnectionError occurred, args=(ProtocolError('Connection aborted.', timeout('The write operation timed out')),)
Traceback (most recent call last):
and then a long list of something there.
Here is my code:
elif message.text == 'Музыка для мотивации':

            audio1 = open('static/806+Fight+Back+-+NEFFEX+(muzic.fm).mp3', 'rb')
            audio2 = open('static/Zack+Hemsey++-+The+Way++(muzic.fm).mp3', 'rb')
            audio3 = open('static/Eminem+feat+Nate+Dogg+-++39+Ti..+(muzic.fm).mp3', 'rb')
            audio4 = open('static/NEFFEX+-+Failure+(muzic.fm).mp3', 'rb')
            audio5 = open('static/Neffex+-+Soldier+(muzic.fm).mp3', 'rb')
            audio6 = open('static/Ratt+-+Round+and+Round+(muzic.fm).mp3', 'rb')
            audio7 = open('static/Rammstein+-+DEUTSCHLAND+(muzic.fm).mp3', 'rb')

            media = [types.InputMediaAudio(audio1), types.InputMediaAudio(audio2), types.InputMediaAudio(audio3), types.InputMediaAudio(audio4), types.InputMediaAudio(audio5), types.InputMediaAudio(audio6), types.InputMediaAudio(audio7)]

            bot.send_media_group(message.chat.id, media)

            audio1.close()
            audio2.close()
            audio3.close()
            audio4.close()
            audio5.close()
            audio6.close()
            audio7.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2020-11-16
@2ord

The logs show an error: timeout!
https://github.com/python-telegram-bot/python-tele...
If I understand correctly, due to the size of the files, they do not have time to fully upload to the Telegram server and a timeout occurs after the time has elapsed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question