024-08-02 16:53:26,709 (init.py:1083 MainThread) ERROR - TeleBot: “Threaded polling exception: A request to the Telegram API was unsuccessful. 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”
2024-08-02 16:53:26,711 (init.py:1085 MainThread) ERROR - TeleBot: “Exception traceback:
Traceback (most recent call last):
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot_init_.py”, line 1074, in _threaded_polling
self.worker_pool.raise_exceptions()
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py”, line 147, in raise_exceptions
raise self.exception_info
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\util.py”, line 90, in run
task(*args, **kwargs)
File "C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot_init.py”, line 6770, in run_middlewares_and_handler
result = handler’function’
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “E:\N_project\trans.py”, line 62, in callback_inline
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
File "C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot_init.py", line 3826, in edit_message_text
result = apihelper.edit_message_text(self.token, text, chat_id, message_id, inline_message_id, parse_mode,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\apihelper.py”, line 1320, in edit_message_text
return make_request(token, method_url, params=payload, method=‘post’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\apihelper.py”, line 162, in make_request
json_result = check_result(method_name, result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Zeto\AppData\Local\Programs\Python\Python311\Lib\site-packages\telebot\apihelper.py”, line 189, 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 is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message
"


import telebot
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from deep_translator import GoogleTranslator
import emoji

API_TOKEN = ‘YOUR_API_TOKEN’
bot = telebot.TeleBot(API_TOKEN)

# Константы для языков и их эмодзи
LANGUAGES = {
‘en’: ‘Английский 🇬🇧’,
‘ru’: ‘Русский 🇷🇺’,
‘es’: ‘Испанский 🇪🇸’,
‘fr’: ‘Французский 🇫🇷’,
‘de’: ‘Немецкий 🇩🇪’
}

source_lang = ‘ru’
target_lang = ‘en’

def translate_text(text, source_language, target_language):
translator = GoogleTranslator(source=source_language, target=target_language)
return translator.translate(text)

def create_language_selection_markup():
markup = InlineKeyboardMarkup()
markup.row_width = 2
for lang_code, lang_name in LANGUAGES.items():
markup.add(InlineKeyboardButton(lang_name, callback_data=f"source{lang_code}“),
InlineKeyboardButton(lang_name, callback_data=f"target{lang_code}”))
markup.add(InlineKeyboardButton(“🔄 Поменять местами”, callback_data=“swap”))
return markup

@bot.message_handler(commands=[‘start’])
def send_welcome(message):
markup = create_language_selection_markup()
bot.send_message(message.chat.id, “Выберите языки для перевода.”, reply_markup=markup)

@bot.message_handler(func=lambda message: message.text.lower().startswith(‘переведи текст’))
def translate_message(message):
text = message.text[len(‘переведи текст’):].strip()
if not text:
bot.reply_to(message, “Пожалуйста, введите текст для перевода.”)
else:
translated_text = translate_text(text, source_lang, target_lang)
bot.reply_to(message, f"Перевод ({LANGUAGES[source_lang].split()[0]} -> {LANGUAGES[target_lang].split()[0]}):\n{translated_text}“)

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
global source_lang, target_lang
if call.message:
if call.data.startswith(“source”):
source_lang = call.data.split(”“)[1]
bot.answer_callback_query(call.id, f"Язык оригинала установлен на {LANGUAGES[source_lang]}”)
elif call.data.startswith(“target”):
target_lang = call.data.split(“”)[1]
bot.answer_callback_query(call.id, f"Язык перевода установлен на {LANGUAGES[target_lang]}")
elif call.data == “swap”:
source_lang, target_lang = target_lang, source_lang
bot.answer_callback_query(call.id, “Языки поменялись местами”)
markup = create_language_selection_markup()
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text=“Выберите языки для перевода.”, reply_markup=markup)

bot.polling()

ИСПОЛЬЗУЙ НОРМАЛЬНЫЕ СКОБКИ И ИСПРАВЬ ОШИБКУ