@mcspekajls

Как исправить ошибку 400 в Телеграм боте?

При написание команды /start боту не реагирует и выдает в логах только ошибку ниже.

import telebot

bot = telebot.TeleBot('мой токен')


@bot.message_handler(commands=['start'])
def start(message):
    bot.send_message(message.chat.id, '</b>Привет</b>', parse_mode='html')


bot.polling(none_stop=True)


Вот логи.
2022-03-23 10:27:38,124 (util.py:66 WorkerThread1) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:\n[b\'{"ok":false,"error_code":400,"description":"Bad Request: can\\\'t parse entities: Unexpected end tag at byte offset 0"}\']',)
Traceback (most recent call last):
  File "C:\Users\dchar\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py", line 60, in run
    task(*args, **kwargs)
  File "X:\pycharm\main.py", line 8, in start
    bot.send_message(message.chat.id, '</b>Привет</b>', parse_mode='html')
  File "C:\Users\dchar\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 600, in send_message
    apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
  File "C:\Users\dchar\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\apihelper.py", line 154, in send_message
    return _make_request(token, method_url, params=payload, method='post')
  File "C:\Users\dchar\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\apihelper.py", line 60, in _make_request
    return _check_result(method_name, result)['result']
  File "C:\Users\dchar\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\apihelper.py", line 79, in _check_result
    raise ApiException(msg, method_name, result)
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: Unexpected end tag at byte offset 0"}']
"
2022-03-23 10:27:38,124 (__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: Unexpected end tag at byte offset 0"}']"
  • Вопрос задан
  • 359 просмотров
Пригласить эксперта
Ответы на вопрос 1
SoreMix
@SoreMix Куратор тега Python
yellow
У вас почему-то два тега закрывающих. Сначала открыть нужно

<b>Привет</b>
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы