B
B
bybacapitan2022-04-18 20:12:19
Python
bybacapitan, 2022-04-18 20:12:19

How to make the bot send a random photo to aiogram?

You need a ready-made code to send a random photo to the bot.
There is such a code, it only works on telebot

@dp.message_handler(content_types=['text'])
def get_text_messages(message):
    if "привет" in message.text.lower():
        photo = open('isxodniki/' + random.choice(os.listdir('isxodniki')), 'rb')
        bot.send_photo(message.from_user.id, photo)

help to adapt to aiogram.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question