Q
Q
qwwwwwty2021-10-25 22:06:27
Python
qwwwwwty, 2021-10-25 22:06:27

How to make a bot send a random picture from a folder, Python Aiogram?

How to make a bot send a random picture from a folder, Python Aiogram? You need to make a list of photos that are on the same path, in the same folder (C:\Users\andis\Desktop\Python\EasyBot). As soon as the list appears, you need the bot to send a random photo via random.choice to the chat

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
antares4045, 2021-10-25
@antares4045

if the list is flat, then os.listdir
if with subfolders os.walk
then open the folder file as a byte stream and send it with the correct mime (this item can be made easier, but more transparent)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question