Код бота
import telebot
token = "232134324324" #Это не настоящий токен, если что
id_channel = "@channel"
bot = telebot.TeleBot(token)
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(id_channel, message, "Howdy, how are you doing?")
@bot.message_handler(func=lambda m: True)
def echo_all(message):
bot.reply_to(id_channel, message.text)
bot.infinity_polling()
Ошибка
2022-03-27 18:24:28,490 (__init__.py:615 MainThread) ERROR - TeleBot: "Infinity polling exception: 'str' object has no attribute 'chat'"
2022-03-27 18:24:28,491 (__init__.py:617 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 611, in infinity_polling
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 658, in polling
self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 720, in __threaded_polling
raise e
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 680, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py", line 135, in raise_exceptions
raise self.exception_info
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py", line 87, in run
task(*args, **kwargs)
File "C:\Users\qqres\Desktop\Новая папка\bot.py", line 13, in echo_all
bot.reply_to(id_channel, message.text)
File "C:\Users\qqres\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py", line 2336, in reply_to
return self.send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)
AttributeError: 'str' object has no attribute 'chat'