I have a problem with a Python chatbot for Telegram. Here is the principle of operation: The user writes a request to the bot, the bot sends a message to me, I write an answer to it, and the bot responds to the user with my answer. The problem in my code is that when the bot sends me a user message and I reply to it, it thinks I'm asking him a question and sends me my own response to the user's request as a question from another user. There is such a function, but it does not work. I tried to make a function to send a message to me, but it worked like an echo, thinking that I was asking a question to the bot. Please help me! import telebot
# Создание экземпляра бота с токеном
bot = telebot.TeleBot('TOKEN')
# Id в telegram
telegram_id = "1113086070"
@bot.message_handler(func=lambda message: True)
def echo_all(message):
if message.from_user.id != telegram_id:
bot.send_message(telegram_id, message.text, disable_notification=message.from_user.id == telegram_id)
else:
reply_to_user(message)
# Отправка сообщения, полученного от пользователя, автору бота
bot.send_message(telegram_id, message.text, disable_notification=(message.from_user.id == telegram_id))
# Обработчик ответов на сообщения от бота
@bot.message_handler(func=lambda message: message.from_user.id == telegram_id)
def reply_to_user(message):
# Отправка ответа бота пользователю
bot.send_message(message.chat.id, message.text, disable_notification=True)
# Запуск бота
bot.polling()