Answer the question
In order to leave comments, you need to log in
How do I return the text sent to the bot (Telebot)?
import telebot
token = 'TOKEN'
channel_name = '@CHANNEL'
bot = telebot.TeleBot(token)
@bot.message_handler(content_types=['text', 'audio'])
def send_message_group(message):
doc_id = message.audio.file_id
bot.send_audio(channel_name, audio=doc_id, caption=message.text)
print(f'\nСообщение успешно доставлено.\nText: {message.text}\nFile_Id: {doc_id}')
if __name__ == '__main__':
bot.infinity_polling()
RESULT:
Сообщение успешно доставлено.
Text: None
File_Id: CQACAgIAsssAAMlYXssssbNssRZSqzDa02kb5ssssssoIBLtEsctssrvOEssA
Answer the question
In order to leave comments, you need to log in
You need to write a message according to HTML tags!
At the end, do not forget to attribute parse_mode!
For example, to send bold or underlined text, you need to sharpen them into the appropriate tags
<b> это жирный текст </b>
<u> это подчеркнутый текст </u>
import telebot
token = 'TOKEN'
channel_name = '@CHANNEL'
bot = telebot.TeleBot(token)
@bot.message_handler(content_types=['text', 'audio'])
def send_message_group(message):
doc_id = message.audio.file_id
bot.send_audio(channel_name, audio=doc_id, caption=message.text, parse_mode='HTML')
print(f'\nСообщение успешно доставлено.\nText: {message.text}\nFile_Id: {doc_id}')
if __name__ == '__main__':
bot.infinity_polling()
# При этом message.text должен быть составлен так "Это обычный шрифт <b> а тут уже жирный шрифт </b> тут снова обычный <u> а тут подчеркнутый текст </u>"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question