Posted by bot in PyCharm. According to the photo, all images from the catalog should be displayed, but when sending a photo or any other team, the chat is empty.

Tell me, what's the problem?

import config import telebot import os bot = telebot.TeleBot(config.token) @bot.message_handler(content_types=['text']) def handle_text(message): if message.text == 'фото': directory = "C:\\Users\\Lamptop\\Desktop\\open" all_files_in_directory = os.listdir(directory) print(all_files_in_directory) for file in all_files_in_directory: img = open(directory + '/' + file, rb) bot.send_chat_action(message.from_user.id, 'upload photo') bot.send_photo(message.from_user.id, img) img.close() 
  • bot.polling(none_stop=True) wrote? - Pavel Durmanov
  • Thanks, forgot, but now writes File "C: /Users/Lamptop/PycharmProjects/untitled/bot.py", line 16, in handle_text img = open (directory + '/' + file, rb) NameError: name 'rb' is not defined. What do I need to do to display images from the folder on the text of the photo? - Nikita Lazarev
  • rb to quote. That is so - 'rb' - Pavel Durmanov

0