PYTHON \ Объясните, пожалуйста, почему когда добавляю в одно из условий parse_mode='Markdown' выбивает ошибку ? :(

    @bot.message_handler(content_types=['text'])
def send_welcome(message):
    if message.text in otvet:
        bot.send_message(message.chat.id, otvet[message.text])
    elif message.text in telefon:
        bot.send_message(message.chat.id, telefon[message.text],parse_mode='Markdown')
    elif message.text not in otvet or telefon:
        bot.send_message(message.chat.id, '*Проверь правильность ввода :( *',parse_mode='Markdown')

Когда добавляю в

elif message.text in telefon:
    bot.send_message(message.chat.id, telefon[message.text],parse_mode='Markdown')

выдает ошибку

    telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: can\'t parse entities: Can\'t find end of the entity starting at byte offset 174"}']
"
2020-04-24 11:49:05,150 (__init__.py:420 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: can\'t parse entities: Can\'t find end of the entity starting at byte offset 174"}']"

В чем может быть проблема?


Ответы (1 шт):

Автор решения: Alexander Sidnenko

Для форматирования текста нужно установить параметр parse_mode. Он имеет два значения: markdown и html. При значении markdown используется форматирование

Сравочник: https://tlgrm.ru/docs/bots/api#markdown-style

→ Ссылка