Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Почему выдает ошибку в командной строке когда хочу загрузить телеграмм бота

Kolya Vlasov Ученик (95), открыт 3 дня назад
вот код:

import telebot;
bot = telebot.TeleBot('...');

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
if message.text == "Привет":
bot.send_message(message.from_ user.id , "Привет, чем я могу тебе помочь?")
elif message.text == "/help":
bot.send_message(message.from_ user.id , "Напиши привет")
else:
bot.send_message(message.from_ user.id , "Я тебя не понимаю. Напиши /help.")

bot.polling(none_stop=True, interval=0)

И вот ошибка:

Traceback (most recent call last):
File "C:\Users\it_student\tg.py", line 13, in <module>
bot.polling(none_stop=True, interval=0)
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 1195, in polling
logger.info('Starting your bot with username: [@%s]', self.user.username)
^^^^^^^^^
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 306, in user
self._user = self.get_me()
^^^^^^^^^^^^^
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\__init__.py", line 1382, in get_me
apihelper.get_me(self.token)
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 202, in get_me
return _make_request(token, method_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 168, in _make_request
json_result = _check_result(method_name, result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\it_student\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\apihelper.py", line 195, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 401. Description: Unauthorized
1 ответ
Похожие вопросы