Try this, note that the path structure will depend on your operating system as well as where the file is actually located:
def telegram_bot_sendphoto(bot_message, image_path):
bot_token = TELEGRAM_BOT_TOKEN #make sure to switch these out
bot_chat_id = TELEGRAM_CHANNEL
bot = telebot.TeleBot(bot_token, parse_mode=None)
# photo = open('/images/sample.jpg', 'rb') #2 possible ways of writing the file path
# photo = "https://example.com/image.pnh"
photo = open(image_path, 'rb') #open the photo for reading
status = bot.send_photo(bot_chat_id, photo, bot_message, timeout=100) #now send the photo with a message and a timeout (how long to wait before giving up if the send fails)
2
Answers
I didn't look far enough....
.send_photo() method has a caption kwarg in...
Try this, note that the path structure will depend on your operating system as well as where the file is actually located: