def text(message): # Отправляем письмо
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == 'yes':
bot.send_message(-100мойайди, 'Принято')
bot.edit_message_text(chat_id=message.chat.id, message_id=messagetoedit.message_id, text=f"Новый текст")
status_id = 'Принято'
if call.data == 'no':
status_id = 'Отказано'
bot.send_message(-100мойайди, 'Отказано')
if message.text == 'Ⓜ Главное меню':
pre_main(message)
validate = URLValidator()
try:
validate(message.text)
keyboard = telebot.types.ReplyKeyboardMarkup(True, False)
keyboard.row('Ⓜ Главное меню')
bot.send_message(message.from_user.id, 'Ваша ссылка \"' + message.text +
'\" получена. Можете вернуться в главное меню ⤵', reply_markup=keyboard)
markup_inline = types.InlineKeyboardMarkup()
item_yes = types.InlineKeyboardButton(text='Принять', callback_data='yes')
item_no = types.InlineKeyboardButton(text='Отказаться', callback_data='no')
markup_inline.add(item_yes, item_no)
messagetoedit = bot.send_message(-100мойайди,
'НОВАЯ ЗАЯВКА! Номер заявки № \n Ссылка: {0}\nАйди: {1}\nИмя: {2}\nФамилия: {3}\nЗаказчик: @{4}\n Статус:'.format(
message.text, message.from_user.id, message.from_user.first_name,
message.from_user.last_name,
message.from_user.username),reply_markup=markup_inline)
except ValidationError as exception:
bot.send_message(message.from_user.id, 'Невалидная ссылка :(')
pre_main(message)
2022-09-20 15:48:53,123 (__init__.py:986 MainThread) ERROR - TeleBot: "Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message can't be edited"
2022-09-20 15:48:53,123 (__init__.py:988 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\__init__.py", line 977, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\util.py", line 154, in raise_exceptions
raise self.exception_info
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\util.py", line 98, in run
task(*args, **kwargs)
File "C:\Users\khaki\Desktop\pythonbotTelegram.py", line 121, in callback_inline
bot.edit_message_text(chat_id=message.chat.id, message_id=messagetoedit.message_id, text=f"Новый текст")
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\__init__.py", line 3409, in edit_message_text
result = apihelper.edit_message_text(self.token, text, chat_id, message_id, inline_message_id, parse_mode,
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\apihelper.py", line 1252, in edit_message_text
return _make_request(token, method_url, params=payload, method='post')
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\apihelper.py", line 161, in _make_request
json_result = _check_result(method_name, result)
File "C:\Users\khaki\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\telebot\apihelper.py", line 188, 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: message can't be edited