import telebot
import random
import time
bot = telebot.TeleBot("XXXXXXXXXXXXXX", parse_mode=None)
library = 'start'
@bot.message_handler(commands=[library])
def send_welcome(message):
chislo = random.randint(1, 10)
while chislo != message.text:
bot.send_message(message, f'Введите число {chislo}')
time.sleep(10)
if chislo == message.text:
bot.send_message(message, "Проверка завершена")
print(message.from_user.username, 'security accses')
else:
bot.send_message(message, "Проверка не завершена")
print(message.from_user.username, 'security don`t accses')
continue
bot.infinity_polling()
2022-12-01 18:14:39,456 (__init__.py:1083 MainThread) ERROR - TeleBot: "Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found"
2022-12-01 18:14:39,456 (__init__.py:1085 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\__init__.py", line 1074, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\util.py", line 156, in raise_exceptions
raise self.exception_info
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\util.py", line 100, in run
task(*args, **kwargs)
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\__init__.py", line 6308, in _run_middlewares_and_handler
result = handler['function'](message)
File "C:\Users\SKvake\PycharmProjects\pythonProject5\main.py", line 14, in send_welcome
bot.send_message(message, f'Введите число {chislo}')
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\__init__.py", line 1549, in send_message
apihelper.send_message(
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\apihelper.py", line 264, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\lib\site-packages\telebot\apihelper.py", line 162, in _make_request
json_result = _check_result(method_name, result)
File "C:\Users\SKvake\PycharmProjects\pythonProject5\venv\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: chat not found