400 ошибка в Телеграм Чат Бот
Ребята подскажите, возникает ошибка в чат боте при отправки документа. По факту документ отправлен, но в консоле при каждой очередной отправки ошибка. Библиотека telebot
Фрагмент кода на отправку
@bot.callback_query_handler(func=lambda call: True)
def inline(c):
# Завление в папки Прочее
if c.data == 'other':
bot.edit_message_text(chat_id=c.message.chat.id,
message_id=c.message.message_id,
text=kb.OTHER,
reply_markup=kb.keyboard_other)
elif c.data == 'APPLICATION_FOR_EMPLOYMENT':
chat_id = c.message.chat.id
message_id = c.message.message_id
bot.send_document(chat_id, dir.application_for_employment(kb.APPLICATION_FOR_EMPLOYMENT))
bot.edit_message_text(chat_id=chat_id,
message_id=message_id,
text=kb.OTHER,
reply_markup=kb.keyboard_other)
2020-05-27 17:57:16,946 (util.py:68 WorkerThread2) 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: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message"}\']',) Traceback (most recent call last): File "C:\Users\Valeria\Desktop\aio_pytelegrambot\evn\lib\site-packages\telebot\util.py", line 62, in run task(*args, **kwargs) File "C:/Users/Valeria/Desktop/aio_pytelegrambot/main.py", line 30, in inline reply_markup=kb.keyboard_other) File "C:\Users\Valeria\Desktop\aio_pytelegrambot\evn\lib\site-packages\telebot__init__.py", line 1090, in edit_message_text disable_web_page_preview, reply_markup) File "C:\Users\Valeria\Desktop\aio_pytelegrambot\evn\lib\site-packages\telebot\apihelper.py", line 682, in edit_message_text return _make_request(token, method_url, params=payload, method='post') File "C:\Users\Valeria\Desktop\aio_pytelegrambot\evn\lib\site-packages\telebot\apihelper.py", line 65, in _make_request return _check_result(method_name, result)['result'] File "C:\Users\Valeria\Desktop\aio_pytelegrambot\evn\lib\site-packages\telebot\apihelper.py", line 84, 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: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message"}'] " 2020-05-27 17:57:16,946 (init.py:443 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: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message"}']"
Ответы (1 шт):
Зачем вы изменяете сообщение после отправки документа?
В консоли даже написано Bad Request: message is not modified
Замените
bot.edit_message_text(chat_id=chat_id,
message_id=message_id,
text=kb.OTHER,
reply_markup=kb.keyboard_other)
на
bot.send_message(c.message.chat.id, '{}'.format(kb.OTHER), reply_markup=kb.keyboard_other)