Here is my code that allows my bot to send random pictures from any folder where the python code is situated.
elif command == 'Hello':
pic_list = glob('*.jpg')
get_random_pic = random.choice(pic_list)
with open(get_random_pic, 'rb') as photo:
telegram_bot.sendPhoto (chat_id, photo)
But the problem of this code is, the code file must be situated in the image folder instead of outside. How can I add the folder location of images in this code?
Aucun commentaire:
Enregistrer un commentaire