W
W
wasp1ck2020-09-03 18:18:38
Python
wasp1ck, 2020-09-03 18:18:38

Why tg bot hangs up after sending audio?

I started getting acquainted with Telegram bots, for a start I decided to learn how to send and receive all types of messages.
I got to sending the audio and ran into this problem:
If you ask the bot to upload a song, then in response, with a rather long delay, it will send an mp3 file that is in the project and will continue to work if you ask it to upload photos, stickers or files (.txt), but as soon as I ask him to upload the song again, he will instantly lie down, and pycharm will write to me:
5f51088f970a3366346189.png
Below I attach a piece of code for sending an audio file:

audio = open(r'song_name.mp3', 'rb')
@bot.message_handler(content_types=['text'])
def send_text(message):
        elif message.text.lower() == 'скинь песню':
        bot.send_document(message.chat.id, audio)
audio.close

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-09-03
@wasp1ck

file inside function open and close

D
Dr. Bacon, 2020-09-03
@bacon

He falls down laughing. Another "bot writer" again missed learning the basics. Also the code can't show properly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question