Обход блокировки юзера (Ошибка 403: bot was blocked by the user)?
Собственно проблема, как научить бота проверять заблокирован ли юзер:
[2018-04-04 06:49:09,913] ERROR in app: Exception on / [POST]
2018-04-04 06:49:09,924: Traceback (most recent call last):
2018-04-04 06:49:09,924: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
2018-04-04 06:49:09,924: response = self.full_dispatch_request()
2018-04-04 06:49:09,924: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
2018-04-04 06:49:09,924: rv = self.handle_user_exception(e)
2018-04-04 06:49:09,924: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
2018-04-04 06:49:09,924: reraise(exc_type, exc_value, tb)
2018-04-04 06:49:09,924: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
2018-04-04 06:49:09,924: raise value
2018-04-04 06:49:09,925: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
2018-04-04 06:49:09,925: rv = self.dispatch_request()
2018-04-04 06:49:09,925: File "/home/Mlpprv/venv/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
2018-04-04 06:49:09,925: return self.view_functions[rule.endpoint](**req.view_args)
2018-04-04 06:49:09,925: File "/home/Mlpprv/bot/main.py", line 2345, in index
2018-04-04 06:49:09,925: reply_markup=user_markup)
2018-04-04 06:49:09,925: File "/home/Mlpprv/venv/lib/python3.6/site-packages/telebot/__init__.py", line 470, in send_message
2018-04-04 06:49:09,925: reply_markup, parse_mode, disable_notification))
2018-04-04 06:49:09,925: File "/home/Mlpprv/venv/lib/python3.6/site-packages/telebot/apihelper.py", line 135, in send_message
2018-04-04 06:49:09,925: return _make_request(token, method_url, params=payload, method='post')
2018-04-04 06:49:09,926: File "/home/Mlpprv/venv/lib/python3.6/site-packages/telebot/apihelper.py", line 56, in _make_request
2018-04-04 06:49:09,926: return _check_result(method_name, result)['result']
2018-04-04 06:49:09,926: File "/home/Mlpprv/venv/lib/python3.6/site-packages/telebot/apihelper.py", line 75, in _check_result
2018-04-04 06:49:09,926: raise ApiException(msg, method_name, result)
2018-04-04 06:49:09,926: telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 403 Forbidden. Response body:
2018-04-04 06:49:09,926: [b'{"ok":false,"error_code":403,"description":"Forbidden: bot was blocked by the user"}']
Есть мысль, что через try-except
Не понимаю, что именно писать в except для обхода ошибки
Бот начинает зацикливаться и, как следствие, падает и перестает вообще отвечать.
После долгих поисков решения ответ оказался прост:
try:
# your code here
pass #это просто держатель места, не обязательно его вводить в коде
except:
# your code here
pass #это просто держатель места, не обязательно его вводить в коде