N
N
NewTermos2020-06-18 20:57:29
Python
NewTermos, 2020-06-18 20:57:29

How to determine that the bot was sent a file?

you need to check what was sent to the bot. If the photo is to do one thing, if the file (document) is another. Used this design:

if m.text:
        msg = bot.send_message(ind, 'Пришлите фото')
        bot.register_next_step_handler(msg, regcheckphoto)
    elif m.file[-1].file_id:
        msg = bot.send_message(ind, 'Пришлите фото')
        bot.register_next_step_handler(msg, regcheckphoto)
    else:
        checkphoto = m.photo[-1].file_id


but it doesn't work. Tell me what to do in such a situation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-06-18
@NewTermos

message.content_type

D
del4pp, 2020-06-18
@del4pp

If you want a photo

@bot.message_handler(content_types=["photo"])
def photo_message(msg):
      *ваш код обработки фото *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question