I want to make it so that the user can upload a photo or video with an inscription, and this bot forwarded this message to a special chat. I tried to do it, but I only did the transfer of pictures without labels. It is necessary that the picture or video with the inscription be thrown off.
import telebot
from telebot import types
bot = telebot.TeleBot('xxxx')
chat_id= xxxxxxx
@bot.message_handler(content_types=['photo'])
def handle_photo(message):
photo = message.photo[-1]
file_info = bot.get_file(photo.file_id)
downloaded_file = bot.download_file(file_info.file_path)
save_path = 'photo.jpg'
with open(save_path, 'wb') as new_file:
new_file.write(downloaded_file)
bot.send_photo(chat_id=chat_id, photo=downloaded_file)
bot.polling(none_stop=True)
You're not passing the text.
There is a message.caption
which holds the text underneath the photo, lets add that to send_photo
:
bot.send_photo(chat_id=chat_id, photo=downloaded_file, caption=message.caption)