Answer the question
In order to leave comments, you need to log in
Implementation of resending a message from the bot to the chat (just text OR photo with text in caption) how?
I am making a small bot, the task is as follows:
Make a bot that, depending on the button pressed, changes the chat_id (channel name) and resends requests from the bot to the channel.
Everything works, depending on the button, the id changes, and TEXT messages are sent to the desired channel.
But I need to make it so that the user can send a Picture (with a caption in the picture with a question) or Text and it is sent according to their preferences. Now only text is sent, I don’t understand how to implement data validation in the handler so that, depending on the type of data, it sends a photo with text or just text.
Below is the implementation of the function:
It is called after selecting a button in the inline keyboard after assigning a channel ID.
@bot.message_handler(func=lambda message: True) ##Пересылка сообщений в канал
def echo_message(message):
bot.send_message(chat_id=chat_id, text=message.text+"\n\nЗапрос от монтера - #"+message.from_user.first_name)
bot.send_message(message.chat.id, "Для создания нового обращения введите команду /start")
@bot.message_handler(content_types = ['photo']) ##фотки эхо
def echo_photo(message):
global chat_id
chat_id = '@xxx'
bot.send_photo(message.chat.id, message.photo[0].file_id, message.caption)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question