Попытался сделать бота из
туториала, однако не судьба. Подскажите, в чем вообще состоит проблема и как ее исправить.
from telegram.ext import Updater
import logging
from telegram.ext import CommandHandler
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id,
text="I'm a bot, please talk to me!")
def main():
TOKEN = "***********************************************"
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
updater.start_polling(poll_interval=1)
if __name__ == "__main__":
main()
Логи:
2020-06-13 19:53:28,594 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016A2F10>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')': /bot{MY_TOKEN}/getMe
2020-06-13 19:53:33,597 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - WARNING - Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016AE070>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')': /bot{MY_TOKEN}/getMe
2020-06-13 19:53:38,598 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016AE190>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')': /bot1226016878:{MY_TOKEN}/getMe
Traceback (most recent call last):
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\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\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\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\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\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\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\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\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\lib\site-packages\telegram\vendor\ptb_urllib3\urllib3\connection.py", line 144, in _new_conn
raise ConnectTimeoutError(
telegram.vendor.ptb_urllib3.urllib3.exceptions.ConnectTimeoutError: (<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016AE2B0>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\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\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\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\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\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\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\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\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\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: /bot1226016878:AAFuppi9tsY0nsvog6WdovI2heHxqR4CASU/getMe (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016AE2B0>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/pycharm_projects/WebDevelopment Python Course/TelegramBOT/main.py", line 31, in <module>
main()
File "C:/pycharm_projects/WebDevelopment Python Course/TelegramBOT/main.py", line 27, in main
updater.start_polling(poll_interval=1)
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\lib\site-packages\telegram\ext\updater.py", line 260, in start_polling
self.job_queue.start()
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\lib\site-packages\telegram\ext\jobqueue.py", line 446, in start
name="Bot:{}:job_queue".format(self._dispatcher.bot.id))
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\lib\site-packages\telegram\bot.py", line 54, in decorator
self.get_me()
File "<decorator-gen-1>", line 2, in get_me
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\lib\site-packages\telegram\bot.py", line 70, in decorator
result = func(*args, **kwargs)
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\lib\site-packages\telegram\bot.py", line 292, in get_me
result = self._request.get(url, timeout=timeout)
File "C:\Users\ДНС\AppData\Local\Programs\Python\Python38\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\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: /bot1226016878:{MY_TOKEN}/getMe (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x0000025E016AE2B0>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))
Process finished with exit code 1