I figure out how to pick a specific picture in a directory.
bot.send_photo(chat_id=chat_id, photo=open('/Users/Iamawesome/Desktop/test/599d6f972525a.jpg', 'rb'))
But how can I pick a random picture? Thank you.
UPDATE I figure out a little bit, but i still don't handle any messages or errors
@BOT.message_handler(commands=['photo'])
def send_rand_photo(message):
photo = random.choice([
x for x in os.listdir(PATH)
if os.path.isfile(os.path.join(PATH, x))
])
with open (photo, "rb") as file:
BOT.send_photo(message.chat.id, file)