Пытаюсь сделать бота для Telegram. Запускаю, а тут такое:
Код:
from telegram import Update
from telegram.ext import CallbackContext
from telegram.ext import Updater
from telegram.ext import Filters
from telegram.ext import MessageHandler
def message_handler(update: Update, context: CallbackContext):
update.message.reply_text(
text='Пример текста',
)
def main():
print('Start')
updater = Updater(
token='%токен%',
use_context=True,
)
updater.dispatcher.add_handler(MessageHandler(filters= Filters.all, callback=message_handler))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
(Токен я скрыл)
Что выводится:
Start
Traceback (most recent call last):
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connection.py", line 140, in _new_conn
conn = connection.create_connection(
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\connection.py", line 83, in create_connection
raise err
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
OSError: [WinError 10051] Сделана попытка выполнить операцию на сокете при отключенной сети
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 614, in urlopen
httplib_response = self._make_request(conn, method, url,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 360, in _make_request
self._validate_conn(conn)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 857, in _validate_conn
super(HTTPSConnectionPool, self)._validate_conn(conn)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 289, in _validate_conn
conn.connect()
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connection.py", line 284, in connect
conn = self._new_conn()
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connection.py", line 149, in _new_conn
raise NewConnectionError(
telegram.vendor.ptb_urllib3.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10051] Сделана попытка выполнить операцию на сокете при отключенной сети
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\utils\request.py", line 225, in _request_wrapper
resp = self._con_pool.request(*args, **kwargs)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py", line 64, in request
return self.request_encode_url(method, url, fields=fields,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\poolmanager.py", line 244, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
return self.urlopen(method, url, body, headers, retries,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
return self.urlopen(method, url, body, headers, retries,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 691, in urlopen
return self.urlopen(method, url, body, headers, retries,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connectionpool.py", line 665, in urlopen
retries = retries.increment(method, url, error=e, _pool=self,
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\retry.py", line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
telegram.vendor.ptb_urllib3.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1099238358:AAGNc9RMX3VYykreARVcr5bIb8diL-oYZ6w/getMe (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10051] Сделана попытка выполнить операцию на сокете при отключенной сети'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Михаил\eclipse-workspace02\Madison\Madison.py", line 28, in
main()
File "C:\Users\Михаил\eclipse-workspace02\Madison\Madison.py", line 24, in main
updater.start_polling()
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\ext\updater.py", line 258, in start_polling
self.job_queue.start()
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\ext\jobqueue.py", line 311, in start
name="Bot:{}:job_queue".format(self._dispatcher.bot.id))
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\bot.py", line 54, in decorator
self.get_me()
File "", line 2, in get_me
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\bot.py", line 67, in decorator
result = func(*args, **kwargs)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\bot.py", line 251, in get_me
result = self._request.get(url, timeout=timeout)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\utils\request.py", line 277, in get
result = self._request_wrapper('GET', url, **urlopen_kwargs)
File "C:\Users\Михаил\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram\utils\request.py", line 231, in _request_wrapper
raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1099238358:AAGNc9RMX3VYykreARVcr5bIb8diL-oYZ6w/getMe (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10051] Сделана попытка выполнить операцию на сокете при отключенной сети'))
Помогите, пожалуйста, не могу решить проблему.