Ошибка ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: unsupported parse_mode

import telebot
import pyowm
from pyowm import OWM
from pyowm.utils import config
from pyowm.utils.config import get_default_config
from pyowm.utils import timestamps

config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = OWM('мой ключ')
bot = telebot.TeleBot("мой токен", config_dict)

@bot.message_handler(content_types=['text'])
def send_message(message):
mgr = owm.weather_manager()
observation = mgr.weather_at_place( message.text )
w = observation.weather
temp = w.temperature('celsius')["temp"]

answer = "В городе " +  message.text + " сейчас " + w.detailed_status + "\n"
answer += "Температура сейчас в районе " + str(temp) + "\n\n"

if temp < 10:
    answer += "Сейчас оч холодно, надо курточку накинуть и подштанники!"
elif temp > 20:
    answer += "Сейчас прохладно, рубашечку или кофту надо накинуть =)"
elif temp > 27:
    answer += "Жарко, можно в футболке фигачить на дачу!!"

bot.send_message(message.chat.id, answer)

bot.polling( none_stop = True )

Выдает ошибку:

2024-06-22 06:29:43,887 (__init__.py:1221 MainThread) ERROR - TeleBot: "Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: unsupported parse_mode"
2024-06-22 06:29:43,890 (__init__.py:1223 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 1215, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\util.py", line 150, in raise_exceptions
    raise self.exception_info
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\util.py", line 93, in run
    task(*args, **kwargs)
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 8573, in _run_middlewares_and_handler
    result = handler['function'](message)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pro10\Desktop\Python\1.py", line 30, in send_message
    bot.send_message(message.chat.id, answer)
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 1755, in send_message
    apihelper.send_message(
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 273, in send_message
    return _make_request(token, method_url, params=payload, method='post')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 168, in _make_request
    json_result = _check_result(method_name, result)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\pro10\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 195, in _check_result
    raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: unsupported parse_mode

Не знаю че делать, помогите)


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

Автор решения: alevtina

Решил проблему добавлением parse_mode="markdown"

bot.send_message(message.chat.id, answer, parse_mode="markdown")
→ Ссылка