@bot.message_handler(commands=['photo'])
def keyboard():
start_keyboard = types.InlineKeyboardMarkup()
menu = types.InlineKeyboardButton(text="фото", callback_data='men')
start_keyboard.add(menu)
bot.send_message(message.chat.id, "получить фото", reply_markup=start_keyboard)
рандомную фотографию из папки проекта ?можно так
import glob, os, random
files = []
for ext in ["png", "jpg", "jpeg"]:
[files.append(file) for file in glob.glob(f"*.{ext}")]
random_file = files[random.randint(0, len(files)-1)]
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == 'men':
with open(random_file, 'rb') as f:
bot.send_media_group(call.message.chat.id, [InputMediaPhoto(f)])