0

Новичок в мире Питона.. Написала код для телеграмм бота. Запускаю в pycharm , написано что нет соединение с сервесом. На pycharm установлен pip, библиотека yTelegramBotAPI. Не судите строго. Не пойму что не так . pip и библиотека yTelegramBotAPI установлена новая версия проверил. код: 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) Я так понял с кодом все ок. Ошибка :

2020-08-09 13:07:59,135 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
"
2020-08-09 13:07:59,136 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:02,529 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
2020-08-09 13:08:02,530 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:03,140 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
2020-08-09 13:08:09,413 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:13,531 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
"
2020-08-09 13:16:38,243 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
1
  • Данная ошибка говорит, что ваш Токен уже используется или вы его ввели не верно. 20 мая 2021 в 1:11

1 ответ 1

1

Видите эту строчку - ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. Это значит что вам нужно проверить ваш Api Бота в Телеграме. Для Этого зайдите в Бот фазер, напишите /mybots и выберете вашего бота, нажмите на кнопку "Api Token" И он вам выдаст токен бота, дальше нажмите "revoke current token" и возьмите новый токен, который будет в том же сообщении. И последнее - поменяйте токен в коде

Bot Father

Я могу ошибаться, но с такой-же ошибкой я справлялся так-же:)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.