Answer the question
In order to leave comments, you need to log in
How to send a random photo via telebot?
I need the bot to send a random photo from a variable, how can I do it?
Answer the question
In order to leave comments, you need to log in
path_list = ["image1.png", "image2.png", "image3.png"] # Это имена файлов в папке с ботом
def callback_worker(call):
if call.data == "rand":
random_path = random.choice(path_list)
with open(random_path, "rb") as file:
bot.send_photo(call.message.chat.id, file.read())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question