Answer the question
In order to leave comments, you need to log in
How to make the bot send a random photo?
Hello, I need to make a bot that will send a random photo when a person writes some text.
def init(update,context):
if "как дела" in message.text.lower():
directory = "/isxodniki"
random_image = random.choice(os.listdir(directory))
bot.send_photo(update.message.chat_id, photo=open(directory + random_image,'rb'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question